Stateless Responses API for text, images, reasoning, function calls, and streaming.
- create - Create Response
- count_input_tokens - Count Input Tokens
Create a response.
Generate a model response from text, image, or file inputs. The response can include text, reasoning, and function calls. Set stream to true to receive Server-Sent Events.
For multi-turn conversations, send the full history in input, including prior output items and function results. Responses are not stored. Only client-executed function tools are supported.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:
res = mistral.responses.create(model="V90", input=[], parallel_tool_calls=True, stream=False, additional_properties={
"truncation": "disabled",
"background": False,
"store": False,
"top_logprobs": 0,
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)| Parameter | Type | Required | Description |
|---|---|---|---|
model |
str | ✔️ | N/A |
input |
models.CreateResponseRequestInput2 | ✔️ | N/A |
instructions |
OptionalNullable[str] | ➖ | N/A |
parallel_tool_calls |
Optional[bool] | ➖ | N/A |
previous_response_id |
OptionalNullable[Any] | ➖ | N/A |
tools |
List[models.CreateResponseRequestTool] | ➖ | N/A |
tool_choice |
Optional[models.CreateResponseRequestToolChoiceUnion] | ➖ | N/A |
reasoning |
OptionalNullable[models.CreateResponseRequestResponsesSupportedReasoning] | ➖ | N/A |
conversation |
OptionalNullable[Any] | ➖ | N/A |
prompt |
OptionalNullable[Any] | ➖ | N/A |
text |
OptionalNullable[models.CreateResponseRequestResponsesTextConfig] | ➖ | N/A |
stream |
Optional[bool] | ➖ | N/A |
max_output_tokens |
OptionalNullable[int] | ➖ | N/A |
temperature |
OptionalNullable[float] | ➖ | N/A |
top_p |
OptionalNullable[float] | ➖ | N/A |
metadata |
Dict[str, str] | ➖ | N/A |
prompt_cache_key |
OptionalNullable[str] | ➖ | N/A |
max_tool_calls |
OptionalNullable[int] | ➖ | N/A |
moderation |
OptionalNullable[Any] | ➖ | N/A |
additional_properties |
Dict[str, Any] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CreateResponseV1ResponsesPostResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |
Count response input tokens.
Count the input tokens for a Responses request without generating a response. The count includes the supplied conversation, instructions, and tool definitions.
Use the same input, instructions, and tools that you plan to send when creating a response. For multi-turn conversations, include prior output items and function results in input.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:
res = mistral.responses.count_input_tokens(model="Corvette", input="<value>", parallel_tool_calls=True, additional_properties={
"truncation": "disabled",
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
model |
str | ✔️ | N/A |
input |
models.CountResponseInputTokensRequestInput2 | ✔️ | N/A |
instructions |
OptionalNullable[str] | ➖ | N/A |
parallel_tool_calls |
Optional[bool] | ➖ | N/A |
previous_response_id |
OptionalNullable[Any] | ➖ | N/A |
tools |
List[models.CountResponseInputTokensRequestTool] | ➖ | N/A |
tool_choice |
Optional[models.CountResponseInputTokensRequestToolChoiceUnion] | ➖ | N/A |
reasoning |
OptionalNullable[models.CountResponseInputTokensRequestResponsesSupportedReasoning] | ➖ | N/A |
conversation |
OptionalNullable[Any] | ➖ | N/A |
prompt |
OptionalNullable[Any] | ➖ | N/A |
text |
OptionalNullable[models.CountResponseInputTokensRequestResponsesTextConfig] | ➖ | N/A |
additional_properties |
Dict[str, Any] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CountResponseInputTokensResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |