Class: Anthropic::Models::CompletionCreateParams

Inherits:
Internal::Type::BaseModel show all
Extended by:
Internal::Type::RequestParameters::Converter
Includes:
Internal::Type::RequestParameters
Defined in:
lib/anthropic/models/completion_create_params.rb

Overview

Instance Attribute Summary collapse

Attributes included from Internal::Type::RequestParameters

#request_options

Instance Method Summary collapse

Methods included from Internal::Type::RequestParameters::Converter

dump_request

Methods included from Internal::Type::RequestParameters

included

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(max_tokens_to_sample:, model:, prompt:, metadata: nil, stop_sequences: nil, temperature: nil, top_k: nil, top_p: nil, betas: nil, request_options: {}) ⇒ Object

Some parameter documentations has been truncated, see Anthropic::Models::CompletionCreateParams for more details.

Parameters:

  • max_tokens_to_sample (Integer)

    The maximum number of tokens to generate before stopping.

  • model (Symbol, String, Anthropic::Models::Model)

    The model that will complete your prompt.nnSee [models](docs.anthropic

  • prompt (String)

    The prompt that you want Claude to complete.

  • metadata (Anthropic::Models::Metadata) (defaults to: nil)

    An object describing metadata about the request.

  • stop_sequences (Array<String>) (defaults to: nil)

    Sequences that will cause the model to stop generating.

  • temperature (Float) (defaults to: nil)

    Amount of randomness injected into the response.

  • top_k (Integer) (defaults to: nil)

    Only sample from the top K options for each subsequent token.

  • top_p (Float) (defaults to: nil)

    Use nucleus sampling.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>) (defaults to: nil)

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

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


# File 'lib/anthropic/models/completion_create_params.rb', line 115

Instance Attribute Details

#betasArray<String, Symbol, Anthropic::Models::AnthropicBeta>?

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

Returns:



113
# File 'lib/anthropic/models/completion_create_params.rb', line 113

optional :betas, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::AnthropicBeta] }

#max_tokens_to_sampleInteger

The maximum number of tokens to generate before stopping.

Note that our models may stop before reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.

Returns:

  • (Integer)


19
# File 'lib/anthropic/models/completion_create_params.rb', line 19

required :max_tokens_to_sample, Integer

#metadataAnthropic::Models::Metadata?

An object describing metadata about the request.

Returns:



50
# File 'lib/anthropic/models/completion_create_params.rb', line 50

optional :metadata, -> { Anthropic::Metadata }

#modelSymbol, ...

The model that will complete your prompt.nnSee [models](docs.anthropic.com/en/docs/models-overview) for additional details and options.

Returns:



27
# File 'lib/anthropic/models/completion_create_params.rb', line 27

required :model, union: -> { Anthropic::Model }

#promptString

The prompt that you want Claude to complete.

For proper response generation you will need to format your prompt using alternating ‘nnHuman:` and `nnAssistant:` conversational turns. For example:

“‘ “nnHuman: userQuestionnnAssistant:” “`

See [prompt validation](docs.claude.com/en/api/prompt-validation) and our guide to [prompt design](docs.claude.com/en/docs/intro-to-prompting) for more details.

Returns:

  • (String)


44
# File 'lib/anthropic/models/completion_create_params.rb', line 44

required :prompt, String

#stop_sequencesArray<String>?

Sequences that will cause the model to stop generating.

Our models stop on ‘“nnHuman:”`, and may include additional built-in stop sequences in the future. By providing the stop_sequences parameter, you may include additional strings that will cause the model to stop generating.

Returns:

  • (Array<String>, nil)


60
# File 'lib/anthropic/models/completion_create_params.rb', line 60

optional :stop_sequences, Anthropic::Internal::Type::ArrayOf[String]

#temperatureFloat?

Deprecated.

Deprecated. Models released after Claude Opus 4.6 do not support setting

temperature. A value of 1.0 of will be accepted for backwards compatibility, all other values will be rejected with a 400 error.

Amount of randomness injected into the response.

Defaults to ‘1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.

Note that even with ‘temperature` of `0.0`, the results will not be fully deterministic.

Returns:

  • (Float, nil)


77
# File 'lib/anthropic/models/completion_create_params.rb', line 77

optional :temperature, Float

#top_kInteger?

Deprecated.

Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value

will be rejected with a 400 error.

Only sample from the top K options for each subsequent token.

Used to remove “long tail” low probability responses. [Learn more technical details here](towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).

Recommended for advanced use cases only.

Returns:

  • (Integer, nil)


91
# File 'lib/anthropic/models/completion_create_params.rb', line 91

optional :top_k, Integer

#top_pFloat?

Deprecated.

Deprecated. Models released after Claude Opus 4.6 do not support setting top_p.

A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.

Use nucleus sampling.

In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by ‘top_p`.

Recommended for advanced use cases only.

Returns:

  • (Float, nil)


107
# File 'lib/anthropic/models/completion_create_params.rb', line 107

optional :top_p, Float