v2

latestOpenAPI 3.1.02026-07-262937191.0 MB
fim

Fim Completion

FIM completion.

post/v1/fim/completions

Request body

modelstring required

ID of the model with FIM to use.

temperaturenumber nullable

What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both. The default value varies depending on the model you are targeting. Call the /models endpoint to retrieve the appropriate value.

top_pnumber nullable

Nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.

max_tokensinteger nullable

The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length.

streamboolean

Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.

random_seedinteger nullable

The seed to use for random sampling. If set, different calls will generate deterministic results.

metadataobject nullable
promptstring required

The text/code to complete.

suffixstring nullable

Optional text/code that adds more context for the model. When given a prompt and a suffix the model will fill what is between them. When suffix is not provided, the model will simply execute completion starting with prompt.

min_tokensinteger nullable

The minimum number of tokens to generate in the completion.

prompt_cache_keystring nullable

Example request

{
  "model": "codestral-latest",
  "prompt": "def",
  "suffix": "return a+b"
}

Response

Successful Response

idstring required
objectstring required
modelstring required
createdinteger required