SpyBara
Go Premium

Documentation 2026-09-14 22:58 UTC to 2026-09-15 22:59 UTC

3 files changed +7 −7. View all changes and history on the product overview
2026
Tue 29 22:57 Mon 28 22:57 Sat 26 23:59 Fri 25 23:58 Thu 24 23:58 Wed 23 23:58 Tue 22 23:57 Mon 21 23:00 Sat 19 23:00 Fri 18 22:59 Thu 17 10:04 Wed 16 20:58 Tue 15 22:59 Mon 14 22:58 Sun 13 15:02 Fri 11 20:00 Thu 10 18:01 Wed 9 23:59 Sat 5 17:01 Fri 4 23:59 Thu 3 23:00 Wed 2 22:59
Details

6 6 

7- **Optimize prompts** to fit within context limits7- **Optimize prompts** to fit within context limits

8- **Estimate costs** before making API calls8- **Estimate costs** before making API calls

9- **Route requests** based on size (e.g., smaller prompts to faster models)9- **Route requests** based on size (for example, smaller prompts to faster models)

10- **Avoid surprises** with images and files—no more character-based estimation10- **Avoid surprises** with images and files—no more character-based estimation

11 11 

12The [input token count endpoint](https://developers.openai.com/api/reference/python/resources/responses/subresources/input_tokens/methods/count) accepts the same input format as the [Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create). Pass text, messages, images, files, tools, or conversations—the API returns the exact count the model will receive.12The [input token count endpoint](https://developers.openai.com/api/reference/resources/responses/subresources/input_tokens/methods/count) accepts the same input format as the [Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create). Pass text, messages, images, files, tools, or conversations—the API returns the exact count the model will receive.

13 13 

14The count includes formatting tokens used to represent request structure, such as message roles and boundaries. These tokens might not appear in the text or fields you tokenize locally.14The count includes formatting tokens used to represent request structure, such as message roles and boundaries. These tokens might not appear in the text or fields you tokenize locally.

15 15 


19 19 

20- **Images and files** are not supported—estimates like `characters / 4` are inaccurate20- **Images and files** are not supported—estimates like `characters / 4` are inaccurate

21- **Tools and schemas** add tokens that are hard to count locally21- **Tools and schemas** add tokens that are hard to count locally

22- **Model-specific behavior** can change tokenization (e.g., reasoning, caching)22- **Model-specific behavior** can change tokenization (for example, reasoning, caching)

23 23 

24The token counting API handles all of these. Use the same payload you would send to `responses.create` and get an accurate count. Then plug the result into your message validation or cost estimation flow.24The token counting API handles all of these. Use the same payload you would send to `responses.create` and get an accurate count. Then plug the result into your message validation or cost estimation flow.

25 25 


781 781 

782## Count tokens with files782## Count tokens with files

783 783 

784[File inputs](https://developers.openai.com/api/docs/guides/file-inputs)—currently PDFs—are supported. Pass `file_id`, `file_url`, or `file_data` as you would for `responses.create`. The token count reflects the model’s full processed input.784[File inputs](https://developers.openai.com/api/docs/guides/file-inputs) (currently PDFs) are supported. Pass `file_id`, `file_url`, or `file_data` as you would for `responses.create`. The token count reflects the model’s full processed input.

785 785 

786## Understand output token counts786## Understand output token counts

787 787 


793 793 

794## API reference794## API reference

795 795 

796For full parameters and response shape, see the [Count input tokens API reference](https://developers.openai.com/api/reference/python/resources/responses/subresources/input_tokens/methods/count). The endpoint is:796For full parameters and response shape, see the [Count input tokens API reference](https://developers.openai.com/api/reference/resources/responses/subresources/input_tokens/methods/count). The endpoint is:

797 797 

798```798```

799POST /v1/responses/input_tokens799POST /v1/responses/input_tokens

libraries.md +1 −1

Details

173<dependency>173<dependency>

174 <groupId>com.openai</groupId>174 <groupId>com.openai</groupId>

175 <artifactId>openai-java</artifactId>175 <artifactId>openai-java</artifactId>

176 <version>4.63.2</version>176 <version>4.63.3</version>

177</dependency>177</dependency>

178```178```

179 179 

quickstart.md +1 −1

Details

190<dependency>190<dependency>

191 <groupId>com.openai</groupId>191 <groupId>com.openai</groupId>

192 <artifactId>openai-java</artifactId>192 <artifactId>openai-java</artifactId>

193 <version>4.63.2</version>193 <version>4.63.3</version>

194</dependency>194</dependency>

195```195```

196 196