Dreams
Dream erstellen
client.beta.dreams.create(params, options?): BetaDreamStartet einen asynchronen Job, der vergangene Sessions nutzt, um eine neu organisierte Version eines Memory Stores zu erzeugen, und gibt den Dream zurück, den du für das Ergebnis abfragen kannst.
Dreams auflisten
client.beta.dreams.list(params?, options?): PageCursor<BetaDream>Listet die Dreams im Workspace auf, die neuesten zuerst.
Dream abrufen
client.beta.dreams.retrieve(dreamID, params?, options?): BetaDreamRuft einen Dream anhand seiner ID ab, um seinen Status, den Ausgabe-Memory-Store und die Token-Nutzung zu prüfen.
Dream abbrechen
client.beta.dreams.cancel(dreamID, params?, options?): BetaDreamStoppt einen Dream mit dem Status pending oder running.
Dream archivieren
client.beta.dreams.archive(dreamID, params?, options?): BetaDreamBlendet einen Dream mit dem Status completed, failed oder canceled aus der Standardliste der Dreams aus.
Models
interface BetaDream { type: "dream"; id; archived_at; /* 11 more */ }An asynchronous job that reads a memory store and past sessions, then writes a reorganized version of that memory store.
An asynchronous job that reads a memory store and past sessions, then writes a reorganized version of that memory store.
By default the dream writes its result to a new memory store and doesn't change the input memory store. With output_behavior set to update_existing, it writes its result into the input memory store instead.
The Dreams API is in research preview: the request and response shapes are volatile and may change without the deprecation period that applies to generally-available endpoints.
See the Dreams guide for what a dream reads and produces.
interface BetaDreamError { type; message }Failure detail for a Dream whose status is failed.
Failure detail for a Dream whose status is failed.
type: stringA code for why the dream failed, such as timeout or internal_error.
A code for why the dream failed, such as timeout or internal_error.
The Dreams guide lists common error codes and when they occur.
A human-readable explanation of why the dream failed.
type BetaDreamInput = BetaDreamMemoryStoreInput | BetaDreamSessionsInputA source that a dream reads, such as a memory store or a set of sessions.
A source that a dream reads, such as a memory store or a set of sessions.
interface BetaDreamMemoryStoreInput { type: "memory_store"; memory_store_id }The memory store that a dream reads, given as an entry in inputs.
The memory store that a dream reads, given as an entry in inputs.
With output_behavior set to update_existing, the dream writes its result into this memory store. Otherwise the dream doesn't change it.
memory_store_id: stringThe ID of the memory store for the dream to read (memstore_...).
The ID of the memory store for the dream to read (memstore_...).
The memory store must be in the same workspace as the dream and must not be archived.
interface BetaDreamSessionsInput { type: "sessions"; session_ids }The sessions that a dream reads, given as an entry in inputs.
The sessions that a dream reads, given as an entry in inputs.
session_ids: Array<string>The IDs of the sessions whose transcripts the dream reads (sesn_...).
The IDs of the sessions whose transcripts the dream reads (sesn_...).
Give 1 to 100 IDs, with no duplicates. Each session must be in the same workspace as the dream. Responses list the IDs in sorted order.
The limits table in the Dreams guide lists all the limits on a dream.
interface BetaDreamMemoryStoreInput { type: "memory_store"; memory_store_id }The memory store that a dream reads, given as an entry in inputs.
The memory store that a dream reads, given as an entry in inputs.
With output_behavior set to update_existing, the dream writes its result into this memory store. Otherwise the dream doesn't change it.
memory_store_id: stringThe ID of the memory store for the dream to read (memstore_...).
The ID of the memory store for the dream to read (memstore_...).
The memory store must be in the same workspace as the dream and must not be archived.
interface BetaDreamMemoryStoreOutput { type: "memory_store"; memory_store_id }The memory store that holds a dream's result, as an entry in outputs.
The memory store that holds a dream's result, as an entry in outputs.
memory_store_id: stringThe ID of the memory store that the dream writes its result to (memstore_...).
The ID of the memory store that the dream writes its result to (memstore_...).
With output_behavior set to create_new, this is a new memory store. With update_existing, it is the input memory store.
interface BetaDreamModelConfig { id; speed }The model that runs a dream, from the request that created it.
The model that runs a dream, from the request that created it.
The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.
id: stringThe ID of the model that runs the dream, as given in the request that created it.
The ID of the model that runs the dream, as given in the request that created it.
speed?: "standard" | "fast"How fast the model generates output for the dream. Always standard.
How fast the model generates output for the dream. Always standard.
interface BetaDreamModelConfigParam { id; speed }The object form of model in a request to create a dream.
The object form of model in a request to create a dream.
id: stringThe ID of the model to run the dream with.
The ID of the model to run the dream with.
The ID can be 1 to 256 characters long.
The limits table in the Dreams guide lists the supported models.
speed?: "standard" | "fast" | nullHow fast the model generates output for the dream. Defaults to standard.
How fast the model generates output for the dream. Defaults to standard.
Dreams accept only standard.
interface BetaDreamOutput { type: "memory_store"; memory_store_id }An entry in a dream's outputs that references the memory store holding its result.
An entry in a dream's outputs that references the memory store holding its result.
memory_store_id: stringThe ID of the memory store that the dream writes its result to (memstore_...).
The ID of the memory store that the dream writes its result to (memstore_...).
With output_behavior set to create_new, this is a new memory store. With update_existing, it is the input memory store.
interface BetaDreamSessionsInput { type: "sessions"; session_ids }The sessions that a dream reads, given as an entry in inputs.
The sessions that a dream reads, given as an entry in inputs.
session_ids: Array<string>The IDs of the sessions whose transcripts the dream reads (sesn_...).
The IDs of the sessions whose transcripts the dream reads (sesn_...).
Give 1 to 100 IDs, with no duplicates. Each session must be in the same workspace as the dream. Responses list the IDs in sorted order.
The limits table in the Dreams guide lists all the limits on a dream.
type BetaDreamStatus = "pending" | "running" | "completed" | 2 moreWhere a dream is in its lifecycle.
Where a dream is in its lifecycle.
completed, failed, and canceled are final: once a dream has one of these statuses, its status doesn't change again.
See the Dreams guide for what each status means.
"pending"The dream is waiting to start and hasn't read its inputs yet.
The dream is waiting to start and hasn't read its inputs yet.
outputs is empty and every usage count is zero.
"running"The dream is reading its inputs and writing its result.
The dream is reading its inputs and writing its result.
usage updates while the dream has this status.
The dream finished and its output memory store holds the complete result.
"failed"The dream stopped with an error, which error describes.
The dream stopped with an error, which error describes.
If outputs references a memory store, that memory store keeps what the dream wrote before it stopped.
"canceled"A cancel request stopped the dream before it reached completed or failed.
A cancel request stopped the dream before it reached completed or failed.
If outputs references a memory store, that memory store keeps what the dream wrote. usage can keep changing after the cancel.
interface BetaDreamUsage { cache_creation_input_tokens; cache_read_input_tokens; input_tokens; output_tokens }The tokens that a dream has used so far.
The tokens that a dream has used so far.
The counts are zero while the dream is pending and update while it is running. They can keep changing after a cancel.
See the Dreams guide for how dreams are billed. See the prompt caching guide for how the input token counts add up.
cache_creation_input_tokens: numberThe dream's input tokens that were written to the prompt cache, for both the 5-minute and 1-hour cache durations.
The dream's input tokens that were written to the prompt cache, for both the 5-minute and 1-hour cache durations.
cache_read_input_tokens: numberThe dream's input tokens that were read from the prompt cache.
The dream's input tokens that were read from the prompt cache.
input_tokens: numberThe dream's input tokens that weren't read from or written to the prompt cache.
The dream's input tokens that weren't read from or written to the prompt cache.
output_tokens: numberThe tokens that the model generated for the dream.
The tokens that the model generated for the dream.
type BetaDreamingError = BetaInvalidRequestError | BetaAuthenticationError | BetaBillingError | 7 more
type BetaOutputBehavior = BetaOutputBehaviorCreateNew | BetaOutputBehaviorUpdateExistingWhich memory store a dream writes its result to. Defaults to create_new when left out of a create request.
Which memory store a dream writes its result to. Defaults to create_new when left out of a create request.
interface BetaOutputBehaviorCreateNew { type: "create_new" }Write the result to a new memory store that starts as a copy of the input memory store. This is the default.
Write the result to a new memory store that starts as a copy of the input memory store. This is the default.
The new memory store is in the same workspace as the dream. The dream doesn't change the input memory store.
interface BetaOutputBehaviorUpdateExisting { type: "update_existing"; memory_store_id }Write the result into the input memory store instead of a new memory store.
Write the result into the input memory store instead of a new memory store.
The credential must be allowed to write memory stores, or the request returns a 403 error. While another update_existing dream on the same memory store hasn't fully stopped, the request returns a 409 error.
memory_store_id: stringThe ID of the memory store for the dream to write its result to (memstore_...). It must be the memory store in the memory_store entry of inputs.
The ID of the memory store for the dream to write its result to (memstore_...). It must be the memory store in the memory_store entry of inputs.
interface BetaOutputBehaviorCreateNew { type: "create_new" }Write the result to a new memory store that starts as a copy of the input memory store. This is the default.
Write the result to a new memory store that starts as a copy of the input memory store. This is the default.
The new memory store is in the same workspace as the dream. The dream doesn't change the input memory store.
interface BetaOutputBehaviorUpdateExisting { type: "update_existing"; memory_store_id }Write the result into the input memory store instead of a new memory store.
Write the result into the input memory store instead of a new memory store.
The credential must be allowed to write memory stores, or the request returns a 403 error. While another update_existing dream on the same memory store hasn't fully stopped, the request returns a 409 error.
memory_store_id: stringThe ID of the memory store for the dream to write its result to (memstore_...). It must be the memory store in the memory_store entry of inputs.
The ID of the memory store for the dream to write its result to (memstore_...). It must be the memory store in the memory_store entry of inputs.
interface BetaTargetStoreHeldError { type: "conflict_error"; message }Returned with status 409 when a request to create a dream sets output_behavior to update_existing and another dream that writes into the same memory store hasn't fully stopped.
Returned with status 409 when a request to create a dream sets output_behavior to update_existing and another dream that writes into the same memory store hasn't fully stopped.
The other dream is pending or running, or it has just stopped and is still finishing its last writes. message gives the ID of the other dream when the server can identify it. If that dream has already reached completed, failed, or canceled, retry after a short wait. Otherwise, wait for the other dream to end or cancel it, then retry. The response sets the x-should-retry header to false.
A human-readable explanation of why the memory store can't be used yet, with the ID of the dream that is using it when the server can identify it.