Skip to main content
Use the quickstart client. Replace uppercase IDs with your resource IDs. Manage assets, collections, and reusable visual references in your fal Assets library. The API key selects the personal or team account. The library enforces the same account access, ownership, and read/write permissions as Assets. See Access and availability for the product rules.

Use the correct asset ID

Use a non-null assetRecordId for library mutations. A search result can have a missing or null assetRecordId. An SDK artifact has its own ID. It is not a library record.

Search assets

All query fields are optional: The response contains items, nextCursor, totalCount, and scopeTruncated. A null totalCount means the total is unavailable. A true scopeTruncated means the search does not cover the full scope.
Keep the filters unchanged when advancing the cursor. Start a new search when you change the filters.

Read asset metadata

library.assets.retrieve(assetRecordId) returns an AgentLibraryAsset. Search results use the same type.

Register and update assets

Register an existing media URL:
Replace the example URL with the HTTPS URL returned by the fal storage client. Arbitrary external hosts are rejected. Upload media with fal.storage.upload before registration. Registration does not upload the file. Optional inputs include size in bytes, collectionId, and favorite. The prompt update applies to uploaded assets. It does not rewrite a generated asset’s original prompt.

Manage tags

library.tags.list returns available asset tags. System tags are excluded. Use library.tags.update(id, change) to change a name or color. Tag names are trimmed, stored in lowercase, and unique within the account. Use library.assets.removeTag(assetRecordId, tagId) to remove one assignment. Deleting a tag removes its assignments without deleting assets.

Find smart entities

library.entities supports all five types through the same methods. List the account’s entities, or filter by type:
Omit types to include all five types. The default limit is 100. The maximum is 1,000. Use an offset to read another page. The response is an array without a pagination cursor. Use search for a case-insensitive substring match against entity names and handles. The search text has a maximum of 255 characters after trimming.
Resolve known handles without searching every page:
resolve accepts an optional types filter. Supply one to 100 handles, with or without the leading @. It returns matching entities in the key’s account. Unknown handles and handles from other accounts are omitted.

Read entity metadata and references

List, resolve, retrieve, create, and update results contain the same typed entity data. Each defining reference includes an assetRecordId and a usable image url. The references array excludes the associated-media gallery. Deleted or expired reference assets are unavailable. metadata contains product-specific fields. Check their shape before use. The character metadata is managed by the product and cannot be set through entity writes.

Create and update smart entities

This example creates one entity of each type. Replace each reference URL with a fal storage URL or an existing asset target before execution.
Names contain 1–255 characters after trimming. Descriptions have a maximum of 2,000 characters. Characters require a description. The other four types allow an omitted or null description. All five types require one to twenty reference images. The product validates storage URLs, asset access, and image types. Handles are unique across the account’s five entity types. Handles have a maximum of 64 characters. The product normalizes handles and derives a handle from the name when omitted during creation. Use entities.checkHandle({ handle, excludeId }) to check availability. Supply excludeId when editing an existing entity. Another request can claim the handle before the write completes.
Updates preserve omitted fields. A supplied referenceImages array replaces the complete defining reference set. The entity type cannot change. Character handles cannot change. The other four types allow handle edits and nullable metadata. Set their handle to null to clear it. Retrieve them by ID or search by name afterward. Handle resolution does not return entities with a cleared handle. Their cover must be one of the defining references. Characters also support a separate cover image, which does not become a defining reference. The gallery contains manually linked assets and recorded generations that used the entity. Adding an asset to the gallery does not add a defining reference.
By default, a reference appears in the gallery only if it also has a manual link or recorded generation usage. Set includeReferences: true to include the defining reference membership too. The default limit is 50. The maximum is 100. Use the returned nextOffset for the next page. A null value ends pagination. Removing a manual link does not delete the asset or erase recorded generation usage. Use entities.setFavorite(id, boolean) and entities.delete(id) to favorite or delete any entity type. Deleting an entity does not delete its source assets. The existing collection favorite, delete, add-asset, and remove-asset methods also accept entity IDs.

Character methods

The library.characters methods keep their existing inputs and results:
Use characters.checkIdentifier(identifier) to check availability before creation. Use characters.update(id, input) to replace the name, description, and complete reference list. Character identifiers cannot change. characters.references(id) reads the resolved reference images. The legacy references response can include a display-only cover marked isCover. Exclude that entry when saving referenceImages. Use library.entities.list({ types: ["character"] }) to list only characters. The asset query’s characterSearchIdentifiers field filters assets by character usage. See the reference for exact inputs and results.

Create a manual collection

A collection name contains 1–255 characters. Optional fields include description, icon, color, coverImageUrl, filters, and parentCollectionId. The description has a maximum of 1,000 characters. The icon and color each have a maximum of 32 characters. Use removeAsset(collectionId, assetRecordId) to remove a manual membership. Adding or removing membership does not upload or delete the asset.

Create a smart collection

Smart collections select assets through a filter expression. This example selects images with a similar description:
A filter uses one of these forms: Comparison fields are endpoint, status, type, source, and created_at. Operators are eq, neq, in, gt, gte, lt, and lte. Values can be strings, numbers, string arrays, or number arrays. Use a value compatible with the field. For in, supply an array. A semantic expression requires exactly one of text, image_url, or video_url. min_similarity ranges from 0 to 1. The maximum filter depth is three levels, including the root expression. Use library.assets.list({ collectionId }) to read matching assets. Manage smart collection membership through its filters.

List and manage collections

library.collections.list({ limit, offset, includeCharacters, includeSmartEntities }) returns an array. includeCharacters defaults to true. It preserves the existing character inclusion behavior. Set includeSmartEntities: true to include all five entity types, regardless of includeCharacters. When includeSmartEntities is false or omitted, includeCharacters controls character inclusion. The limit ranges from 1 to 1,000. The offset ranges from 0 to 10,000. This method does not return nextCursor.
Updates accept name, description, icon, color, coverImageUrl, and filters. Use null to clear a nullable field. The name cannot be null. An AgentLibraryCollection includes metadata, type, filters, parent ID, handle fields, favorite state, and timestamps. It also includes assetCount and previewAssets. The count can be null. Types are manual, smart, character, prop, environment, style, and scene. Use library.entities to create or update an entity’s defining data. Use library.collections to create manual or smart collections.

Handle uncertain writes

Library writes are sent once. They do not accept an idempotency key. After a network error, retrieve the asset or list the collections before repeating the change. All methods accept optional signal and timeoutMs as their final argument.