stream
option is set to true
), the response is in MIME type text/event-stream
. Otherwise, the content type is application/json
.
You can view the schema of the streamed sequence of chunk objects in streaming mode here.Authorizations
Headers
ID of team to run requests as (optional parameter).
Body
Code of the model to use. See available model list.
"meta-llama-3.1-8b-instruct"
The prompt (i.e., input text) to generate completions for. Either prompt
or tokens
field is required.
"Say this is a test!"
Same as the above bad_words
field, but receives token sequences instead of text phrases. This is similar to Hugging Face's bad_word_ids
argument.
Text phrases that should not be generated.
For a bad word phrase that contains N tokens, if the first N-1 tokens appears at the last of the generated result, the logit for the last token of the phrase is set to -inf.
Before checking whether a bard word is included in the result, the word is converted into tokens.
We recommend using bad_word_tokens
because it is clearer.
For example, after tokenization, phrases "clear" and " clear" can result in different token sequences due to the prepended space character.
Defaults to empty list.
A list of flattened embedding vectors used for replacing the tokens at the specified indices provided via token_index_to_replace
.
If this exceeds 1, every ngram of that size occurring in the input token sequence cannot appear in the generated result. 1 means that this mechanism is disabled (i.e., you cannot prevent 1-gram from being generated repeatedly). Only allowed for encoder-decoder models. Defaults to 1. This is similar to Hugging Face's encoder_no_repeat_ngram_size
argument.
Penalizes tokens that have already appeared in the input tokens. Should be positive value. 1.0 means no penalty. Only allowed for encoder-decoder models. See Keskar et al., 2019 for more details. This is similar to Hugging Face's encoder_repetition_penalty
argument.
A list of endpoint sentence tokens.
Number between -2.0 and 2.0. Positive values penalizes tokens that have been sampled, taking into account their frequency in the preceding text. This penalization diminishes the model's tendency to reproduce identical lines verbatim.
Include the log probabilities on the logprobs most likely output tokens, as well the chosen tokens.
The maximum number of tokens to generate. For decoder-only models like GPT, the length of your input tokens plus max_tokens
should not exceed the model's maximum length (e.g., 2048 for OpenAI GPT-3). For encoder-decoder models like T5 or BlenderBot, max_tokens
should not exceed the model's maximum output length. This is similar to Hugging Face's max_new_tokens
argument.
200
The maximum number of tokens including both the generated result and the input tokens. Only allowed for decoder-only models. Only one argument between max_tokens
and max_total_tokens
is allowed. Default value is the model's maximum length. This is similar to Hugging Face's max_length
argument.
A scaling factor used to determine the minimum token probability threshold. This threshold is calculated as min_p
multiplied by the probability of the most likely token. Tokens with probabilities below this scaled threshold are excluded from sampling. Values range from 0.0 (inclusive) to 1.0 (inclusive). Higher values result in stricter filtering, while lower values allow for greater diversity. The default value of 0.0 disables filtering, allowing all tokens to be considered for sampling.
The minimum number of tokens to generate. Default value is 0. This is similar to Hugging Face's min_new_tokens
argument.
This field is unsupported when response_format
is specified.
The minimum number of tokens including both the generated result and the input tokens. Only allowed for decoder-only models. Only one argument between min_tokens
and min_total_tokens
is allowed. This is similar to Hugging Face's min_length
argument.
The number of independently generated results for the prompt. Defaults to 1. This is similar to Hugging Face's num_return_sequences
argument.
If this exceeds 1, every ngram of that size can only occur once among the generated result (plus the input tokens for decoder-only models). 1 means that this mechanism is disabled (i.e., you cannot prevent 1-gram from being generated repeatedly). Defaults to 1. This is similar to Hugging Face's no_repeat_ngram_size
argument.
Number between -2.0 and 2.0. Positive values penalizes tokens that have been sampled at least once in the existing text.
Penalizes tokens that have already appeared in the generated result (plus the input tokens for decoder-only models). Should be positive value (1.0 means no penalty). See keskar et al., 2019 for more details. This is similar to Hugging Face's repetition_penalty
argument.
The enforced format of the model's output.
Note that the content of the output message may be truncated if it exceeds the max_tokens
. You can check this by verifying that the finish_reason
of the output message is length
.
For more detailed information, please refer here.
Important
You must explicitly instruct the model to produce the desired output format using a system prompt or user message (e.g., You are an API generating a valid JSON as output.
).
Otherwise, the model may result in an unending stream of whitespace or other characters.
When response_format
is specified, min_tokens
field is unsupported.
Seed to control random procedure. If nothing is given, the API generate the seed randomly, use it for sampling, and return the seed along with the generated result. When using the n
argument, you can pass a list of seed values to control all of the independent generations.
When one of the stop phrases appears in the generation result, the API will stop generation. The stop phrases are excluded from the result. Defaults to empty list.
Stop generating further tokens when generated token corresponds to any of the tokens in the sequence.
Whether to stream generation result. When set true, each token will be sent as server-sent events once generated.
Options related to stream.
It can only be used when stream: true
.
Sampling temperature. Smaller temperature makes the generation result closer to greedy, argmax (i.e., top_k = 1
) sampling. Defaults to 1.0. This is similar to Hugging Face's temperature
argument.
A list of token indices where to replace the embeddings of input tokens provided via either tokens
or prompt
.
Limits sampling to the top k tokens with the highest probabilities. Values range from 0 (no filtering) to the model's vocabulary size (inclusive). The default value of 0 applies no filtering, allowing all tokens.
1
Keeps only the smallest set of tokens whose cumulative probabilities reach top_p
or higher. Values range from 0.0 (exclusive) to 1.0 (inclusive). The default value of 1.0 includes all tokens, allowing maximum diversity.
The probability that XTC (Exclude Top Choices) filtering will be applied for each sampling decision. When XTC is triggered, high-probability tokens above the xtc_threshold
are excluded except for the least likely viable token. This stochastic activation allows for a balance between standard sampling and creativity-boosting exclusion filtering. Values range from 0.0 (inclusive) to 1.0 (inclusive), where 0.0 means XTC is never applied, 1.0 means XTC is always applied when viable tokens exist, and intermediate values provide probabilistic activation. The default value of 0.0 disables XTC filtering.
A probability threshold used to identify “top choice” tokens for exclusion in XTC (Exclude Top Choices) sampling. Tokens with probabilities at or above this threshold are considered viable candidates, and all but the least likely viable token are excluded from sampling. This option reduces the dominance of highly probable tokens while preserving some diversity by keeping the least confident “top choice.” Values range from 0.0 (inclusive) to 1.0 (inclusive). Higher values make the filtering more selective by requiring higher probabilities to trigger exclusion, while lower values apply filtering more broadly. The default value of 0.0 disables XTC filtering entirely.
Response
Successfully generated completions.
A unique ID of the completion.
The object type, which is always set to text_completion
.
"text_completion"
The model to generate the completion. For dedicated endpoints, it returns the endpoint id.