Skip to content

Get input token counts

POST https://api.fastapi.ai/v1/responses/input_tokens

Returns input token counts of the request.

Request body


conversation string or object Optional Defaults to null
The conversation that this response belongs to. Items from this conversation are prepended to input_items for this response request. Input items and output items from this response are automatically added to this conversation after this response completes.


input string or array Optional
Text, image, or file inputs to the model, used to generate a response.


instructions string Optional
A system (or developer) message inserted into the model's context. When used along with previous_response_id, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.


model string Optional
Model ID used to generate the response, like gpt-4o or o3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.


parallel_tool_calls boolean Optional Defaults to true
Whether to allow the model to run tool calls in parallel.


previous_response_id string Optional
The unique ID of the previous response to the model. Use this to create multi-turn conversations. Cannot be used in conjunction with conversation.


reasoning object Optional
gpt-5 and o-series models only. Configuration options for reasoning models.


text object Optional
Configuration options for a text response from the model. Can be plain text or structured JSON data.


tool_choice string or object Optional
How the model should select which tool (or tools) to use when generating a response.


tools array Optional
An array of tools the model may call while generating a response.


truncation string Optional
The truncation strategy to use for the model response.

  • auto: If the input to this Response exceeds the model's context window size, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation.
  • disabled (default): If the input size will exceed the context window size for a model, the request will fail with a 400 error.

Returns


The input token counts.

bash
{
  "object": "response.input_tokens",
  "input_tokens": 11
}

Example

bash
curl https://api.fastapi.ai/v1/responses/input_tokens \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $FAST_API_KEY" \
  -d '{"model":"gpt-5","input":"Tell me a joke."}'

那年我双手插兜, 让bug稳如老狗