Class CompletionCreateParams
-
- All Implemented Interfaces:
-
com.anthropic.core.Params
public final class CompletionCreateParams implements Params
Legacy Create a Text Completion.
The Text Completions API is a legacy API. We recommend using the Messages API going forward.
Future models and features will not be compatible with Text Completions. See our migration guide for guidance in migrating from Text Completions to Messages.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classCompletionCreateParams.BuilderA builder for CompletionCreateParams.
public final classCompletionCreateParams.Body
-
Method Summary
Modifier and Type Method Description final Optional<List<AnthropicBeta>>betas()Optional header to specify the beta version(s) you want to use. final LongmaxTokensToSample()The maximum number of tokens to generate before stopping. final Modelmodel()The model that will complete your prompt. final Stringprompt()The prompt that you want Claude to complete. final Optional<Metadata>metadata()An object describing metadata about the request. final Optional<List<String>>stopSequences()Sequences that will cause the model to stop generating. final Optional<Double>temperature()Amount of randomness injected into the response. final Optional<Long>topK()Only sample from the top K options for each subsequent token. final Optional<Double>topP()Use nucleus sampling. final JsonField<Long>_maxTokensToSample()Returns the raw JSON value of maxTokensToSample. final JsonField<Model>_model()Returns the raw JSON value of model. final JsonField<String>_prompt()Returns the raw JSON value of prompt. final JsonField<Metadata>_metadata()Returns the raw JSON value of metadata. final JsonField<List<String>>_stopSequences()Returns the raw JSON value of stopSequences. final JsonField<Double>_temperature()Returns the raw JSON value of temperature. final JsonField<Long>_topK()Returns the raw JSON value of topK. final JsonField<Double>_topP()Returns the raw JSON value of topP. final Map<String, JsonValue>_additionalBodyProperties()final Headers_additionalHeaders()final QueryParams_additionalQueryParams()final CompletionCreateParams.BuildertoBuilder()final CompletionCreateParams.Body_body()Headers_headers()The full set of headers in the parameters, including both fixed and additional headers. QueryParams_queryParams()The full set of query params in the parameters, including both fixed and additional query params. Booleanequals(Object other)IntegerhashCode()StringtoString()final static CompletionCreateParams.Builderbuilder()Returns a mutable builder for constructing an instance of CompletionCreateParams. -
-
Method Detail
-
betas
final Optional<List<AnthropicBeta>> betas()
Optional header to specify the beta version(s) you want to use.
-
maxTokensToSample
final Long maxTokensToSample()
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.
-
model
final Model model()
The model that will complete your prompt.\n\nSee models for additional details and options.
-
prompt
final String prompt()
The prompt that you want Claude to complete.
For proper response generation you will need to format your prompt using alternating
\n\nHuman:and\n\nAssistant:conversational turns. For example:"\n\nHuman: {userQuestion}\n\nAssistant:"See prompt validation and our guide to prompt design for more details.
-
stopSequences
final Optional<List<String>> stopSequences()
Sequences that will cause the model to stop generating.
Our models stop on
"\n\nHuman:", 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.
-
temperature
final Optional<Double> temperature()
Amount of randomness injected into the response.
Defaults to
1.0. Ranges from0.0to1.0. Usetemperaturecloser to0.0for analytical / multiple choice, and closer to1.0for creative and generative tasks.Note that even with
temperatureof0.0, the results will not be fully deterministic.
-
topK
final Optional<Long> topK()
Only sample from the top K options for each subsequent token.
Used to remove "long tail" low probability responses. Learn more technical details here.
Recommended for advanced use cases only. You usually only need to use
temperature.
-
topP
final Optional<Double> topP()
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. You should either altertemperatureortop_p, but not both.Recommended for advanced use cases only. You usually only need to use
temperature.
-
_maxTokensToSample
final JsonField<Long> _maxTokensToSample()
Returns the raw JSON value of maxTokensToSample.
Unlike maxTokensToSample, this method doesn't throw if the JSON field has an unexpected type.
-
_model
final JsonField<Model> _model()
Returns the raw JSON value of model.
Unlike model, this method doesn't throw if the JSON field has an unexpected type.
-
_prompt
final JsonField<String> _prompt()
Returns the raw JSON value of prompt.
Unlike prompt, this method doesn't throw if the JSON field has an unexpected type.
-
_metadata
final JsonField<Metadata> _metadata()
Returns the raw JSON value of metadata.
Unlike metadata, this method doesn't throw if the JSON field has an unexpected type.
-
_stopSequences
final JsonField<List<String>> _stopSequences()
Returns the raw JSON value of stopSequences.
Unlike stopSequences, this method doesn't throw if the JSON field has an unexpected type.
-
_temperature
final JsonField<Double> _temperature()
Returns the raw JSON value of temperature.
Unlike temperature, this method doesn't throw if the JSON field has an unexpected type.
-
_topK
final JsonField<Long> _topK()
Returns the raw JSON value of topK.
Unlike topK, this method doesn't throw if the JSON field has an unexpected type.
-
_topP
final JsonField<Double> _topP()
Returns the raw JSON value of topP.
Unlike topP, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalBodyProperties
final Map<String, JsonValue> _additionalBodyProperties()
-
_additionalHeaders
final Headers _additionalHeaders()
-
_additionalQueryParams
final QueryParams _additionalQueryParams()
-
toBuilder
final CompletionCreateParams.Builder toBuilder()
-
_body
final CompletionCreateParams.Body _body()
-
_headers
Headers _headers()
The full set of headers in the parameters, including both fixed and additional headers.
-
_queryParams
QueryParams _queryParams()
The full set of query params in the parameters, including both fixed and additional query params.
-
builder
final static CompletionCreateParams.Builder builder()
Returns a mutable builder for constructing an instance of CompletionCreateParams.
The following fields are required:
.maxTokensToSample() .model() .prompt()
-
-
-
-