Class: Anthropic::Resources::Beta::Dreams

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/dreams.rb,
sig/anthropic/resources/beta/dreams.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Dreams

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Dreams.

Parameters:



220
221
222
# File 'lib/anthropic/resources/beta/dreams.rb', line 220

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(dream_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaDream

Hide a completed, failed, or canceled dream from the default list of dreams.

Archiving a pending or running dream returns a 400 error, so cancel it first. Archiving an archived dream returns it unchanged. An archived dream can still be fetched by ID. Archiving can't be undone.

See the Dreams guide to learn more about archiving dreams.

Some parameter documentations has been truncated, see Models::Beta::DreamArchiveParams for more details.

Parameters:

  • dream_id (String) —

    The ID of the dream to archive (drm_...).

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Optional header to specify the beta version(s) you want to use.

  • workspace_id (String) —

    Optional header to select the Workspace for this request. The value is a Workspa

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



168
169
170
171
172
173
174
175
176
177
# File 'lib/anthropic/resources/beta/dreams.rb', line 168

def archive(dream_id, params = {})
  parsed, options = Anthropic::Beta::DreamArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/dreams/%1$s/archive?beta=true", dream_id],
    headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"),
    model: Anthropic::Beta::BetaDream,
    options: {extra_headers: {"anthropic-beta" => "dreaming-2026-04-21"}, **options}
  )
end

#cancel(dream_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaDream

Stop a pending or running dream.

The response shows status as canceled, unless the dream reached completed or failed first. usage can keep changing after the response. Canceling a canceled dream returns it unchanged. Canceling a completed or failed dream returns a 400 error.

See the Dreams guide to learn more about canceling dreams.

Some parameter documentations has been truncated, see Models::Beta::DreamCancelParams for more details.

Parameters:

  • dream_id (String) —

    The ID of the dream to cancel (drm_...).

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Optional header to specify the beta version(s) you want to use.

  • workspace_id (String) —

    Optional header to select the Workspace for this request. The value is a Workspa

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



206
207
208
209
210
211
212
213
214
215
# File 'lib/anthropic/resources/beta/dreams.rb', line 206

def cancel(dream_id, params = {})
  parsed, options = Anthropic::Beta::DreamCancelParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/dreams/%1$s/cancel?beta=true", dream_id],
    headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"),
    model: Anthropic::Beta::BetaDream,
    options: {extra_headers: {"anthropic-beta" => "dreaming-2026-04-21"}, **options}
  )
end

#create(inputs:, model:, instructions: nil, output_behavior: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaDream

Start an asynchronous job that uses past sessions to produce a reorganized version of a memory store and get back the dream to poll for the result.

By default the dream writes its result to a new memory store and doesn't change the input memory store. The response has status set to pending and an empty outputs array. Poll the dream until status is completed, failed, or canceled.

See the Dreams guide to learn more about creating dreams.

Some parameter documentations has been truncated, see Models::Beta::DreamCreateParams for more details.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/anthropic/resources/beta/dreams.rb', line 41

def create(params)
  parsed, options = Anthropic::Beta::DreamCreateParams.dump_request(params)
  header_params = {betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"}
  @client.request(
    method: :post,
    path: "v1/dreams?beta=true",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Anthropic::Beta::BetaDream,
    options: {extra_headers: {"anthropic-beta" => "dreaming-2026-04-21"}, **options}
  )
end

#list(created_at_gt: nil, created_at_lt: nil, include_archived: nil, limit: nil, page: nil, statuses: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::BetaDream>

List the dreams in the workspace, newest first.

Archived dreams are left out unless include_archived is true.

See the Dreams guide for how to page through dreams.

Some parameter documentations has been truncated, see Models::Beta::DreamListParams for more details.

Parameters:

  • created_at_gt (Time) —

    Query param: Return only dreams created after this time (exclusive), in RFC 3339

  • created_at_lt (Time) —

    Query param: Return only dreams created before this time (exclusive), in RFC 333

  • include_archived (Boolean) —

    Query param: Whether to include archived dreams. Defaults to false.

  • limit (Integer) —

    Query param: The maximum number of dreams to return, from 1 to 100. Defaults to

  • page (String) —

    Query param: The cursor for the page to return, taken from next_page in a prev

  • statuses (Array<Symbol, Anthropic::Models::Beta::BetaDreamStatus>) —

    Query param: Return only dreams that have one of these statuses.

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Header param: Optional header to specify the beta version(s) you want to use.

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/anthropic/resources/beta/dreams.rb', line 123

def list(params = {})
  query_params = [:created_at_gt, :created_at_lt, :include_archived, :limit, :page, :statuses]
  parsed, options = Anthropic::Beta::DreamListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v1/dreams?beta=true",
    query: query.transform_keys(created_at_gt: "created_at[gt]", created_at_lt: "created_at[lt]"),
    headers: parsed.except(*query_params).transform_keys(
      betas: "anthropic-beta",
      workspace_id: "anthropic-workspace-id"
    ),
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Beta::BetaDream,
    options: {extra_headers: {"anthropic-beta" => "dreaming-2026-04-21"}, **options}
  )
end

#retrieve(dream_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaDream

Get a dream by ID to check its status, output memory store, and token usage.

Archived dreams are returned too.

See the Dreams guide for how to poll a dream and what each status means.

Some parameter documentations has been truncated, see Models::Beta::DreamRetrieveParams for more details.

Parameters:

  • dream_id (String) —

    The ID of the dream to get (drm_...).

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Optional header to specify the beta version(s) you want to use.

  • workspace_id (String) —

    Optional header to select the Workspace for this request. The value is a Workspa

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



78
79
80
81
82
83
84
85
86
87
# File 'lib/anthropic/resources/beta/dreams.rb', line 78

def retrieve(dream_id, params = {})
  parsed, options = Anthropic::Beta::DreamRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/dreams/%1$s?beta=true", dream_id],
    headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"),
    model: Anthropic::Beta::BetaDream,
    options: {extra_headers: {"anthropic-beta" => "dreaming-2026-04-21"}, **options}
  )
end