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.

    • Constructor Detail

    • Method Detail

      • 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.

        See 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

        @Deprecated(message = "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.") final Optional<Double> temperature()

        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.

      • topK

        @Deprecated(message = "Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.") 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.

      • topP

        @Deprecated(message = "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.") 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.

        Recommended for advanced use cases only.

      • _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.

      • _temperature

        @Deprecated(message = "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.") 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

        @Deprecated(message = "Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.") 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

        @Deprecated(message = "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.") 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.

      • _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.