Releases: sanity-io/client
v7.6.0
7.6.0 (2025-06-13)
Features
- transform: adds support for optional imageUrl param in for target.operation image-description (#1105) (c47214f)
Agent Action: Transform – Image descriptions
Targeting images outside the document (URL)
If the source image is available on a https URL outside the target document, it is possible to get a description for it using imageUrl
.
Example:
client.agent.action.transform({
schemaId,
documentId,
instruction: 'describe the image in great detail',
target: [
{
path: ['imageDescription'],
operation: {
type: 'image-description',
imageUrl: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2',
},
},
],
})
v7.5.0
7.5.0 (2025-06-06)
Image descriptions
Images can be transformed to a textual description by targeting a string
, text
or Portable Text field (array
with block
)
with operation: {type: 'image-description'}
.
Custom instructions for image description targets will be used to generate the description.
Targeting image fields
If a target is a descendant field of an image object, no sourcePath
is required in the operation:
For example:
target: {path: ['image', 'description'], operation: {type: 'image-description'} }
target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image
target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }
Targeting non-image fields
If the target image description lives outside an image object, use the sourcePath
option to specify the path to the image field.
sourcePath
must be an image or image asset field.
For example:
target: {path: ['description'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }
target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }
target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }
This PR was generated with Release Please. See documentation.
v7.4.1
v7.4.0
7.4.0 (2025-05-29)
Highlights
Agent Actions no longer mutate published documents by default (#1092) (7587e2c)
API Breaking Change: As of this release, Agent Actions will never write to published documents by default. Use forcePublishedWrite: true
in the request to write to published documents.
Agent Actions require apiVersion: 'vX'
. Therefore, this is new behavior will apply to all users of agent actions, regardless of client version. Using this release (or later) will be required to opt out of the new behavior using forcePublishedWrite: true
.
As of this going out, by default:
- Agent Actions will not mutate a published document. It will use a drafts id if a published id is provided
- Operations on drafts will get initial state from published doc if no draft exists.
- Callers should check the _id in the response as needed; when a publishedId is provided a drafts.publishedId will be returned.
To opt out of the default behavior, pass forcePublishedWrite: true
Exceptions:
- Documents with liveEdit: true in the schema definition will behave as if forcePublishedWrite: true, and also will not accept drafts IDs in requests.
- Versioned Ids on the form "versions.release-id.document-id" will always behave as if forcePublishedWrite: true, and will not consider draft nor published state; only the version itself.
New Agent Actions
Patch: a schema aware patch API(#1091) (0bf6de3)
The client.patch
and client.transaction
API are not schema aware. These allows patching documents any way you want, but the operations will not fail if they deviate from the document schema.
To ensure schema-compliant operation, client.agent.action.patch
is available. It will ensure that provided paths and values adhere to the document schema, ensure no duplicate keys are inserted, and merge object values so set operations don't accidentally remove existing values. Learn more in the quick start.
await client.agent.action.patch({
schemaId: '_.schema.default',
documentId: 'documentId',
target: {
path: ['metadata', 'title'], // path to metadata.title
operation: 'set',
value: 'New title'
}
})
Prompt: Make LLM requests without mutating documents (#1078) (d6b08b7)
agent.action.prompt
is an API for sending instructions to the LLM and receiving text or json back. Useful if you want to use the same Sanity client and feed in your content, but don't want to incorporate a third-party library or API key. Learn more in the quick start.
await client.agent.action.prompt({
instruction: `Give me some ideas for a blog post
about using AI with structured content.`
})
Generate and Transform for images(#1093) (475214d)
Generating images
Generate can generate images the same way as AI Assist, for images that have been configured using AI Assist schema options.
To generate images without changing the schema, you can now directly target an image asset path.
For example, all the following will generate an image into the provided asset:
target: {path: ['image', 'asset'] }
target: {path: 'image', include: ['asset'] }
Image generation can be combined with regular content targets:
target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]
As Generate happens in a single LLM pass, the image will be contextually related to other generated content.
Transforming images
To transform an existing image, directly target an image asset path with Transform.
For example, all the following will transform the image into the provided asset:
target: {path: ['image', 'asset'] }
target: {path: 'image', include: ['asset'] }
Image transform can be combined with regular content targets:
target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]
Image transform can have per-path instructions, just like any other target paths:
target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }
See the updated image generation documentation for more details.
Bug Fixes
v7.3.0
v7.2.2
v7.2.1
v7.2.0
7.2.0 (2025-05-09)
Features
Content Release and Document Version operations (#1067) (9b80bd8)
The client now has complete abstractions and types for all Content Lake release and version actions.
These are available to be used directly interfacing with the server action:
client.action(
{
actionType: 'sanity.action.document.version.create',
publishedId: 'bike-123',
document: {
_id: 'versions.new-bike-release.bike-123'
_type: 'bike'
}
}
)
Or additionally through method abstractions which provide more unified concepts such as releaseId and publishedId, in addition to client side guards on mismatching IDs:
client.createVersion(
{
publishedId: 'bike-123',
releaseId: 'new-bike-release',
document: {
_type: 'bike'
}
}
)
Important
Deprecation notice of some document server actions
The discard
and replaceDraft
actions now have deprecation notices in the client, to reflect updates on the underlying Content Lake API.
discard
is superseded by discardVersion
and replaceDraft
by replaceVersion