Fim
POST /v1/fim/completions
Fim Completion
FIM completion.
Request Example
{
"prompt": "def"
}
Request Body
max_tokens
integer | nullThe 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.
metadata
map<any> | nullmin_tokens
integer | nullThe minimum number of tokens to generate in the completion.
model
stringID of the model with FIM to use.
Example:
codestral-latest
Default Value: "codestral-2404"
prompt
string* requiredThe text/code to complete.
Example:
def
prompt_cache_key
string | nullrandom_seed
integer | nullThe seed to use for random sampling. If set, different calls will generate deterministic results.
stop
string | array<string> | nullStop generation if this token is detected. Or if one of these tokens is detected when providing an array
stream
booleanWhether 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.
Default Value: false
suffix
string | nullOptional 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.
Example:
return a+b
temperature
number | nullWhat 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_p
number | nullNucleus 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.
Responses
Successful Response
ChatCompletionChoice
finish_reason
"stop" | "length" | "model_length" | "error" | "tool_calls"* requiredExample:
stop
index
integer* requiredExample:
0
logprobs
ChatCompletionResponseChoiceLogprobs | nullChatCompletionResponseChoiceLogprobs
ChatCompletionResponseTokenLogprobsTopK
bytes
array<integer>* requiredlogprob
number* requiredtoken
string* requiredtoken_id
integer* requiredtop_logprobs
array<ChatCompletionResponseTokenLogprobs> | nullChatCompletionResponseTokenLogprobs
bytes
array<integer>* requiredlogprob
number* requiredtoken
string* requiredtoken_id
integer* requiredmessage
AssistantMessageAssistantMessage
content
string | array<TextChunk | ImageURLChunk | DocumentURLChunk | ReferenceChunk | FileChunk | ThinkChunk | AudioChunk | ResourceChunk | ResourceLinkChunk> | nullTextChunk
text
string* requiredtype
stringDefault Value: "text"
ImageURLChunk
{"type":"image_url","image_url":"data:image/png;base64,iVBORw0"}
ImageURL
detail
"low" | "auto" | "high"url
string* requiredtype
stringDefault Value: "image_url"
DocumentURLChunk
document_name
string | nullThe filename of the document
document_url
string* requiredtype
stringDefault Value: "document_url"
ReferenceChunk
reference_ids
array<integer | string>* requiredtype
stringDefault Value: "reference"
FileChunk
file_id
string* requiredtype
stringDefault Value: "file"
ThinkChunk
closed
booleanWhether the thinking chunk is closed or not. Currently only used for prefixing.
Default Value: true
signature
string | nullSignature to replay some reasoning blocks across turns.
TextChunk
text
string* requiredtype
stringDefault Value: "text"
ToolReferenceChunk
description
string | nullfavicon
string | nulltitle
string* requiredtool
"web_search" | "web_search_premium" | "code_interpreter" | "image_generation" | "document_library" | "mistral_mcp" | string* requiredtype
stringDefault Value: "tool_reference"
url
string | nullReferenceChunk
reference_ids
array<integer | string>* requiredtype
stringDefault Value: "reference"
type
stringDefault Value: "thinking"
AudioChunk
input_audio
string* requiredtype
stringDefault Value: "input_audio"
ResourceChunk
type
stringDefault Value: "resource"
uri
string* requiredResourceLinkChunk
metadata
map<string | integer | number | boolean> | nulltype
stringDefault Value: "resource_link"
uri
string* requiredprefix
booleanSet this to true when adding an assistant message as prefix to condition the model response. The role of the prefix message is to force the model to start its answer by the content of the message.
Default Value: false
role
stringDefault Value: "assistant"
tool_calls
array<ToolCall> | nullToolCall
FunctionCall
arguments
map<any> | string* requiredname
string* requiredid
stringindex
integerDefault Value: 0
type
"function"messages
array<DeltaMessage>DeltaMessage
content
string | array<TextChunk | ImageURLChunk | DocumentURLChunk | ReferenceChunk | FileChunk | ThinkChunk | AudioChunk | ResourceChunk | ResourceLinkChunk> | nullTextChunk
text
string* requiredtype
stringDefault Value: "text"
ImageURLChunk
{"type":"image_url","image_url":"data:image/png;base64,iVBORw0"}
ImageURL
detail
"low" | "auto" | "high"url
string* requiredtype
stringDefault Value: "image_url"
DocumentURLChunk
document_name
string | nullThe filename of the document
document_url
string* requiredtype
stringDefault Value: "document_url"
ReferenceChunk
reference_ids
array<integer | string>* requiredtype
stringDefault Value: "reference"
FileChunk
file_id
string* requiredtype
stringDefault Value: "file"
ThinkChunk
closed
booleanWhether the thinking chunk is closed or not. Currently only used for prefixing.
Default Value: true
signature
string | nullSignature to replay some reasoning blocks across turns.
TextChunk
text
string* requiredtype
stringDefault Value: "text"
ToolReferenceChunk
description
string | nullfavicon
string | nulltitle
string* requiredtool
"web_search" | "web_search_premium" | "code_interpreter" | "image_generation" | "document_library" | "mistral_mcp" | string* requiredtype
stringDefault Value: "tool_reference"
url
string | nullReferenceChunk
reference_ids
array<integer | string>* requiredtype
stringDefault Value: "reference"
type
stringDefault Value: "thinking"
AudioChunk
input_audio
string* requiredtype
stringDefault Value: "input_audio"
ResourceChunk
type
stringDefault Value: "resource"
uri
string* requiredResourceLinkChunk
metadata
map<string | integer | number | boolean> | nulltype
stringDefault Value: "resource_link"
uri
string* requiredindex
integer | nullIf the completion returns multiple messages, this is to specify which message this delta is for.
metadata
map<any> | nullrole
string | nulltool_call_id
string | nulltool_calls
array<ToolCall> | nullToolCall
FunctionCall
arguments
map<any> | string* requiredname
string* requiredid
stringindex
integerDefault Value: 0
type
"function"prompt_logprobs
ChatCompletionResponseChoiceLogprobs | nullChatCompletionResponseChoiceLogprobs
ChatCompletionResponseTokenLogprobsTopK
bytes
array<integer>* requiredlogprob
number* requiredtoken
string* requiredtoken_id
integer* requiredtop_logprobs
array<ChatCompletionResponseTokenLogprobs> | nullChatCompletionResponseTokenLogprobs
bytes
array<integer>* requiredlogprob
number* requiredtoken
string* requiredtoken_id
integer* requiredcreated
integer* requiredExample:
1702256327
id
string* requiredExample:
cmpl-e5cc70bb28c444948073e77776eb30ef
model
string* requiredExample:
codestral-latest
object
string* requiredExample:
chat.completion
UsageInfo
completion_tokens
integerDefault Value: 0
prompt_audio_seconds
integer | nullprompt_tokens
integerDefault Value: 0
prompt_tokens_details
PromptTokensDetails | nullToken usage details for the prompt.
PromptTokensDetails
Token usage details for the prompt.
audio_tokens
integerDefault Value: 0
cached_tokens
integerDefault Value: 0
service_tier
string | nullThe service tier at which the request was processed: standard or priority.
total_tokens
integerDefault Value: 0