POST
/responses/input_tokensGet input token counts
Returns the number of input tokens in a request prepared for a response. Supply the model and input configuration you want counted, including any conversation state, tools, text settings, reasoning settings, or truncation strategy. The response identifies the token-count object and provides the calculated input_tokens value.
- RetriesRetries up to 2×, 500ms backoff, 30s timeout.
Optional response input configuration used to calculate input token counts.
modelstringoptional
The model ID used to generate the response, such as `gpt-4o` or `o3`.
inputstring | arrayoptional
Text, image, or file inputs to the model.
previous_response_idstringoptional
The unique ID of a previous response used to provide multi-turn conversation state; do not combine it with `conversation`.
toolsarray<Function>optional
The tools the model may call while generating the response.
textobjectoptional
Configuration options for plain-text or structured JSON output.
reasoningobjectoptional
Configuration options for reasoning models, including reasoning mode, effort, summary, and context settings.
truncationstringdeprecatedoptional
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.
instructionsstringoptional
System or developer instructions inserted into the model context.
personalitystringoptional
A model-owned style preset to apply to this request. Omit this parameter to use the model's default style. Supported values may expand over time. Values must be at most 64 characters.
conversationstring | objectoptional
The conversation to which the response belongs; its items are prepended to the request input and updated after completion.
tool_choicestring | objectoptional
Controls how the model selects tools when generating the response.
parallel_tool_callsbooleanoptional
Whether the model may run tool calls in parallel.
200Returns an object with `object` set to `response.input_tokens` and the calculated `input_tokens` count.
objectstringrequired
input_tokensintegerrequired
429Returned when the request is rejected because the rate limit has been exceeded.
errorobjectrequired
Error handling
A 429 is returned when the request exceeds the rate limit. previous_response_id cannot be used together with conversation, and truncation must be auto or disabled when provided; personality must be no more than 64 characters.