Count input tokens
Count the tokens in the fully rendered input for a Responses request, without generating or storing a response. The count includes resolved previous_response_id history, current instructions and tools, media, and server-injected prompt scaffolding. Conversation resources are not supported.
POST /responses/input_tokens
Count tokens in the fully rendered input for a Responses request without generating or storing a response.
Request body
Content Type: application/json
Response
HTTP 200 — Success
Content Type: application/json
pythonimport jsonimport osimport requestsresponse = requests.post("https://api.meta.ai/v1/responses/input_tokens",headers={"Authorization": f"Bearer {os.environ['MODEL_API_KEY']}","Content-Type": "application/json",},json={"model": "muse-spark-1.3","input": "What is the capital of France?",},)response.raise_for_status()print(json.dumps(response.json(), indent=2))
shellcurl -X POST "https://api.meta.ai/v1/responses/input_tokens" \-H "Authorization: Bearer $MODEL_API_KEY" \-H "Content-Type: application/json" \-d '{"model": "muse-spark-1.3","input": "What is the capital of France?"}'
For usage examples and rate-limit guidance, see the Responses feature page.