Returns input token counts of the request. Returns an object with `object` set to `response.input_tokens` and an `input_tokens` count. Args: conversation: The conversation that this response belongs to. Items from this conversation are prepe
(
self,
*,
conversation: Optional[input_token_count_params.Conversation] | Omit = omit,
input: Union[str, Iterable[ResponseInputItemParam], None] | Omit = omit,
instructions: Optional[str] | Omit = omit,
model: Optional[str] | Omit = omit,
parallel_tool_calls: Optional[bool] | Omit = omit,
personality: Union[str, Literal["friendly", "pragmatic"]] | Omit = omit,
previous_response_id: Optional[str] | Omit = omit,
reasoning: Optional[Reasoning] | Omit = omit,
text: Optional[input_token_count_params.Text] | Omit = omit,
tool_choice: Optional[input_token_count_params.ToolChoice] | Omit = omit,
tools: Optional[Iterable[ToolParam]] | Omit = omit,
truncation: Literal["auto", "disabled"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
)
| 44 | return InputTokensWithStreamingResponse(self) |
| 45 | |
| 46 | def count( |
| 47 | self, |
| 48 | *, |
| 49 | conversation: Optional[input_token_count_params.Conversation] | Omit = omit, |
| 50 | input: Union[str, Iterable[ResponseInputItemParam], None] | Omit = omit, |
| 51 | instructions: Optional[str] | Omit = omit, |
| 52 | model: Optional[str] | Omit = omit, |
| 53 | parallel_tool_calls: Optional[bool] | Omit = omit, |
| 54 | personality: Union[str, Literal["friendly", "pragmatic"]] | Omit = omit, |
| 55 | previous_response_id: Optional[str] | Omit = omit, |
| 56 | reasoning: Optional[Reasoning] | Omit = omit, |
| 57 | text: Optional[input_token_count_params.Text] | Omit = omit, |
| 58 | tool_choice: Optional[input_token_count_params.ToolChoice] | Omit = omit, |
| 59 | tools: Optional[Iterable[ToolParam]] | Omit = omit, |
| 60 | truncation: Literal["auto", "disabled"] | Omit = omit, |
| 61 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 62 | # The extra values given here take precedence over values defined on the client or passed to this method. |
| 63 | extra_headers: Headers | None = None, |
| 64 | extra_query: Query | None = None, |
| 65 | extra_body: Body | None = None, |
| 66 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 67 | ) -> InputTokenCountResponse: |
| 68 | """ |
| 69 | Returns input token counts of the request. |
| 70 | |
| 71 | Returns an object with `object` set to `response.input_tokens` and an |
| 72 | `input_tokens` count. |
| 73 | |
| 74 | Args: |
| 75 | conversation: The conversation that this response belongs to. Items from this conversation are |
| 76 | prepended to `input_items` for this response request. Input items and output |
| 77 | items from this response are automatically added to this conversation after this |
| 78 | response completes. |
| 79 | |
| 80 | input: Text, image, or file inputs to the model, used to generate a response |
| 81 | |
| 82 | instructions: A system (or developer) message inserted into the model's context. When used |
| 83 | along with `previous_response_id`, the instructions from a previous response |
| 84 | will not be carried over to the next response. This makes it simple to swap out |
| 85 | system (or developer) messages in new responses. |
| 86 | |
| 87 | model: Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a |
| 88 | wide range of models with different capabilities, performance characteristics, |
| 89 | and price points. Refer to the |
| 90 | [model guide](https://platform.openai.com/docs/models) to browse and compare |
| 91 | available models. |
| 92 | |
| 93 | parallel_tool_calls: Whether to allow the model to run tool calls in parallel. |
| 94 | |
| 95 | personality: A model-owned style preset to apply to this request. Omit this parameter to use |
| 96 | the model's default style. Supported values may expand over time. Values must be |
| 97 | at most 64 characters. |
| 98 | |
| 99 | previous_response_id: The unique ID of the previous response to the model. Use this to create |
| 100 | multi-turn conversations. Learn more about |
| 101 | [conversation state](https://platform.openai.com/docs/guides/conversation-state). |
| 102 | Cannot be used in conjunction with `conversation`. |
| 103 |