Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

Get input token counts

POST
/responses/input_tokens

Returns input token counts of the request.

Returns an object with object set to response.input_tokens and an input_tokens count.

Get input token counts

curl -X POST https://api.openai.com/v1/responses/input_tokens \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
      "model": "gpt-6-astra",
      "input": "Tell me a joke."
    }'
Response example
{
  "object": "response.input_tokens",
  "input_tokens": 11
}
Body Parameters
JSON
conversation: optional string or ResponseConversationParam { id } or 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: optional string or array of EasyInputMessage { content, role, phase, type } or Message { content, role, status, type } or ResponseOutputMessage { id, content, role, 3 more } or 30 more or null

Text, image, or file inputs to the model, used to generate a response

instructions: optional string or null

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: optional string or null

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: optional boolean or null

Whether to allow the model to run tool calls in parallel.

personality: optional string or "friendly" or "pragmatic"

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.

previous_response_id: optional string or null

The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about conversation state. Cannot be used in conjunction with conversation.

reasoning: optional Reasoning { context, effort, generate_summary, 2 more } or null

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

text: optional object { format, verbosity } or null

Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more:

tool_choice: optional ToolChoiceOptions or ToolChoiceAllowed { mode, tools, type } or ToolChoiceTypes { type } or 6 more or null

Controls which tool the model should use, if any.

tools: optional array of Function { name, parameters, strict, 6 more } or FileSearch { type, vector_store_ids, filters, 2 more } or Computer { type } or 13 more or null

An array of tools the model may call while generating a response. You can specify which tool to use by setting the tool_choice parameter.

truncation: optional "auto" or "disabled"

Deprecated.

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. On some models, trimming can begin earlier because the API subtracts the model’s maximum output allowance from its input limit before counting tokens.
  • disabled (default): If the input size will exceed the context window size for a model, the request will fail with a 400 error.
One of the following:
"auto"
"disabled"
Returns
input_tokens: integer
object: "response.input_tokens" (default: "response.input_tokens")
Returns Examples
Response example
{
  "object": "response.input_tokens",
  "input_tokens": 11
}