xAI has introduced new public URL endpoints for its Files API, allowing developers to generate permanent, unauthenticated links to stored assets. This functionality is designed for sharing content outside an API-keyed environment, while the original file remains accessible via the authenticated content endpoint.
Key Points
- The xAI Files API now supports creating public URLs for existing files.
- These public URLs are permanent and do not require authentication for access.
- Files shared via public URLs can still be fetched through the authenticated content endpoint.
- Public URLs can be revoked at any time using the
POST /v1/files/{file_id}/public-url/revokeendpoint. - The revocation process is idempotent; calling it on a file without an active public URL will return
revoked: falsewithout an error. - The xAI Management API provides endpoints for managing collections and documents, accessible via
https://management-api.x.ai/. - Collection management requires authentication using an xAI Management API Key with an
Authorization: Bearer <your xAI Management API key>header.
Context
According to xAI, the new public URL feature allows for external sharing of assets like images, videos, and PDFs. The underlying file remains unaffected and can still be accessed through authenticated methods. The Collections API, as detailed by xAI, offers functionalities for managing collections and documents, including listing, filtering, and retrieving document metadata within a collection. This API supports filtering on various parameters such as collection_id, collection_name, created_at, and documents_count for collections, and name, content_type, size_bytes, created_at, and document-level fields for documents.
Why It Matters
This update provides developers with a direct method to share stored assets publicly without exposing their API keys, which can simplify content distribution workflows. The ability to revoke public URLs offers control over shared content, while the detailed collection management features support organized data handling within applications.
What To Do
- Review the xAI Files API documentation for details on creating and revoking public URLs.
- Explore the xAI Management API documentation to understand collection and document management capabilities.
- Test the public URL creation and revocation endpoints with various file types.
- Note the filtering and sorting options available for collections and documents in the Collections API.
