SpyBara
Go Premium

Documentation 2026-11-10 23:02 UTC to 2026-11-11 23:57 UTC

15 files changed +117 −265. View all changes and history on the product overview
2026
Fri 13 23:58 Thu 12 22:57 Wed 11 23:57 Tue 10 23:02 Mon 9 23:02 Sun 8 22:59 Sat 7 22:59 Fri 6 23:00 Thu 5 23:00 Wed 4 22:58 Tue 3 22:58 Mon 2 23:58 Sun 1 23:00
Details

37 37 

38- How much your API call costs, as you pay per token38- How much your API call costs, as you pay per token

39- How long your API call takes, as writing more tokens takes more time39- How long your API call takes, as writing more tokens takes more time

40- Whether your API call works at all, as total tokens must be below the model's maximum limit (4097 tokens for `gpt-3.5-turbo`)40- Whether your API call works at all, as input and output tokens must fit within the model's context window (see the [model pages](https://developers.openai.com/api/docs/models) for limits)

41 41 

42Both input and output tokens count toward these quantities. For example, if your API call used 10 tokens in the message input and you received 20 tokens in the message output, you would be billed for 30 tokens. Note however that for some models the price per token is different for tokens in the input vs. the output (see the [pricing](https://openai.com/api/pricing) page for more information).42Both input and output tokens count toward these quantities. For example, if your API call used 10 tokens in the message input and you received 20 tokens in the message output, you would be billed for 30 tokens. Note however that for some models the price per token is different for tokens in the input vs. the output (see the [pricing](https://openai.com/api/pricing) page for more information).

43 43 

44To see how many tokens are used by an API call, check the `usage` field in the API response (for example, `response['usage']['total_tokens']`).44To see how many tokens are used by an API call, check the `usage` field in the API response (for example, `response['usage']['total_tokens']`).

45 45 

46Chat models like `gpt-3.5-turbo` and `gpt-4-turbo-preview` use tokens in the same way as the models available in the completions API, but because of their message-based formatting, it's more difficult to count how many tokens will be used by a conversation.46Chat models use additional tokens for message formatting, so counting the text alone doesn't give the full input token count. For Responses API requests, use the [input token counting API](https://developers.openai.com/api/docs/guides/token-counting) to count tokens before creating a response.

47 47 

48 48 

49 49 

50Below is an example function for counting tokens for messages passed to `gpt-3.5-turbo-0613`.50The examples below use `gpt-3.5-turbo-0613`, which was [retired on September 13, 2024](https://developers.openai.com/api/docs/deprecations#2023-11-06-chat-model-updates).

51 51 

52The exact way that messages are converted into tokens may change from model to model. So when future model versions are released, the answers returned by this function may be only approximate.52This local counter applies only to text messages for that historical snapshot. Message formatting varies by model.

53 53 

54```python54```python

55import tiktoken

56 

57 

55def num_tokens_from_messages(messages, model="gpt-3.5-turbo-0613"):58def num_tokens_from_messages(messages, model="gpt-3.5-turbo-0613"):

56 """Returns the number of tokens used by a list of messages."""59 """Returns the number of tokens used by a list of messages."""

57 try:60 try:

58 encoding = tiktoken.encoding_for_model(model)61 encoding = tiktoken.encoding_for_model(model)

59 except KeyError:62 except KeyError:

60 encoding = tiktoken.get_encoding("cl100k_base")63 encoding = tiktoken.get_encoding("cl100k_base")

61 if model == "gpt-3.5-turbo-0613": # note: future models may deviate from this64 if model == "gpt-3.5-turbo-0613":

62 num_tokens = 065 num_tokens = 0

63 for message in messages:66 for message in messages:

64 num_tokens += (67 num_tokens += 3 # Message formatting overhead.

65 4 # every message follows <im_start>{role/name}\n{content}<im_end>\n

66 )

67 for key, value in message.items():68 for key, value in message.items():

68 num_tokens += len(encoding.encode(value))69 num_tokens += len(encoding.encode(value))

69 if key == "name": # if there's a name, the role is omitted70 if key == "name":

70 num_tokens += -1 # role is always required and always 1 token71 num_tokens += 1 # Extra formatting for a named message.

71 num_tokens += 2 # every reply is primed with <im_start>assistant72 num_tokens += 3 # Assistant reply priming.

72 return num_tokens73 return num_tokens

73 raise ValueError(74 raise ValueError(

74 f"num_tokens_from_messages() only supports gpt-3.5-turbo-0613, not {model}."75 f"num_tokens_from_messages() only supports gpt-3.5-turbo-0613, not {model}."


76```77```

77 78 

78 79 

79Next, create a message and pass it to the function defined above to see the token count, this should match the value returned by the API usage parameter:80Count the example messages locally:

80 81 

81```python82```python

82messages = [83messages = [


113model = "gpt-3.5-turbo-0613"114model = "gpt-3.5-turbo-0613"

114 115 

115print(f"{num_tokens_from_messages(messages, model)} prompt tokens counted.")116print(f"{num_tokens_from_messages(messages, model)} prompt tokens counted.")

116# Should show ~126 total_tokens117# 129 prompt tokens counted.

117```118```

118 119 

119 120 

120To confirm the number generated by our function above is the same as what the API returns, create a new Chat Completion:121The following historical example shows how to read the API's prompt token count. It cannot run against the retired model:

121 122 

122```javascript123```javascript

123import OpenAI from "openai";124import OpenAI from "openai";


172 173 

173Each message passed to the API consumes the number of tokens in the content, role, and other fields, plus a few extra for behind-the-scenes formatting. This may change slightly in the future.174Each message passed to the API consumes the number of tokens in the content, role, and other fields, plus a few extra for behind-the-scenes formatting. This may change slightly in the future.

174 175 

175If a conversation has too many tokens to fit within a model’s maximum limit (for example, more than 4097 tokens for `gpt-3.5-turbo` or more than 128k tokens for `gpt-4o`), you will have to truncate, omit, or otherwise shrink your text until it fits. Beware that if a message is removed from the messages input, the model will lose all knowledge of it.176If a conversation has too many tokens to fit within a model’s context window, you will have to truncate, omit, or otherwise shrink your text until it fits. Beware that if a message is removed from the messages input, the model will lose all knowledge of it.

176 177 

177Note that long conversations are more likely to receive incomplete replies. For example, a `gpt-3.5-turbo` conversation that is 4090 tokens long will have its reply cut off after just 6 tokens.178Leave room in the context window for output tokens, and check the model's maximum output token limit when setting an output budget.

178 179 

179## Parameter details180## Parameter details

180 181 

guides/batch.md +4 −36

Details

45 45 

46#### Moderation input examples46#### Moderation input examples

47 47 

48Text-only request:48This input file contains a text-only request followed by a request with text and image input:

49 49 

50```jsonl50```jsonl

51{51{"custom_id": "moderation-text-1", "method": "POST", "url": "/v1/moderations", "body": {"model": "omni-moderation-latest", "input": "This is a harmless test sentence."}}

52 "custom_id": "moderation-text-1",52{"custom_id": "moderation-mm-1", "method": "POST", "url": "/v1/moderations", "body": {"model": "omni-moderation-latest", "input": [{"type": "text", "text": "Describe this image"}, {"type": "image_url", "image_url": {"url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"}}]}}

53 "method": "POST",

54 "url": "/v1/moderations",

55 "body": {

56 "model": "omni-moderation-latest",

57 "input": "This is a harmless test sentence."

58 }

59}

60```

61 

62Request with text and image input:

63 

64```jsonl

65{

66 "custom_id": "moderation-mm-1",

67 "method": "POST",

68 "url": "/v1/moderations",

69 "body": {

70 "model": "omni-moderation-latest",

71 "input": [

72 {

73 "type": "text",

74 "text": "Describe this image"

75 },

76 {

77 "type": "image_url",

78 "image_url": {

79 "url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"

80 }

81 }

82 ]

83 }

84}

85```53```

86 54 

87Prefer referencing remote assets with `image_url` (instead of base64 blobs) to55Prefer referencing remote assets with `image_url` (instead of base64 blobs) to


508{"id": "batch_req_1", "custom_id": "request-1", "response": {"status_code": 200, "request_id": "req_1", "body": {"id": "resp_1", "object": "response", "status": "completed", "output": [{"type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "blue"}]}]}}, "error": null}476{"id": "batch_req_1", "custom_id": "request-1", "response": {"status_code": 200, "request_id": "req_1", "body": {"id": "resp_1", "object": "response", "status": "completed", "output": [{"type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "blue"}]}]}}, "error": null}

509```477```

510 478 

511The output file will automatically be deleted 30 days after the batch is complete.479By default, batch output and error files expire 30 days after file creation. Set `output_expires_after` in the [batch creation request](https://developers.openai.com/api/reference/resources/batches/methods/create) to choose an expiration period from 1 hour to 30 days, measured from file creation.

512 480 

513### 6. Cancel a batch481### 6. Cancel a batch

514 482 

Details

9 9 

10> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.10> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

11 11 

12- [GPT-6 Astra](https://developers.openai.com/api/docs/models/gpt-6-astra)12<a id="gpt-6-astra-gpt-6-astra"></a>

13 

14 **Highest intelligence**

15 

16 For the most demanding reasoning, coding, and professional work.

17 

18- [GPT-6.1 Sol](https://developers.openai.com/api/docs/models/gpt-6.1-sol)

19 

20 **Balanced speed, cost, and intelligence**

21 

22 Near-Astra performance for complex work at a lower cost.

23 

24- [GPT-6.1 Terra](https://developers.openai.com/api/docs/models/gpt-6.1-terra)

25 

26 **Fast and efficient**

27 

28 For visual reasoning, precise computer use, and clear, natural writing.

29 

30- [GPT-6 Luna](https://developers.openai.com/api/docs/models/gpt-6-luna)

31 

32 **Fastest and most cost-effective**

33 

34 Strong performance for focused, high-volume tasks.

35 

36 

37 

38To get started, set `model` in a [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses) request. If you already use [`gpt-6-sol`](https://developers.openai.com/api/docs/models/gpt-6-sol), review the [migration guidance](#migration-quickstart) before switching to GPT-6.1 Sol.

39 

40### GPT-6 Astra

41 

42GPT-6 Astra is our most intelligent model yet, with state-of-the-art performance in computer use, browsing, software engineering, science, and professional work. It can carry out multi-step workflows across code, browsers, and professional software. In [several evaluations](https://openai.com/index/gpt-6-astra/), Astra achieved stronger results using substantially fewer output tokens. Its estimated API cost per task was lower than earlier models despite its higher per-token pricing.

43 

44GPT-6 Astra is also our most aligned model yet. It excels at exercising care, respecting task boundaries, and communicating transparently. When instructions leave room for interpretation, it uses the context it has to fill in routine gaps and asks focused questions when the answer could change the outcome. It incorporates new requirements, changes course when asked, and answers side questions without losing track of the broader task.

45 

46All GPT-6 Astra users also have access to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) and the new [Ultrafast mode](https://developers.openai.com/api/docs/guides/ultrafast-mode) for our fastest API speeds.

47 

48<a id="gpt-61-sol"></a>13<a id="gpt-61-sol"></a>

49<a id="gpt-6.1-sol"></a>14<a id="gpt-6.1-sol"></a>

50 15<a id="gpt-6-astra-gpt-61-sol"></a>

51### GPT-6.1 Sol

52 

53GPT-6.1 Sol delivers near-Astra performance at a lower cost for complex coding,

54computer use, and professional work. It supports `low`, `medium` (default),

55`high`, `xhigh`, and `max` reasoning effort.

56 

57See the [model page](https://developers.openai.com/api/docs/models/gpt-6.1-sol) for specifications and pricing.

58 

59<a id="gpt-61-terra"></a>16<a id="gpt-61-terra"></a>

60<a id="gpt-6.1-terra"></a>17<a id="gpt-6.1-terra"></a>

18<a id="gpt-6-astra-gpt-61-terra"></a>

61 19 

62### GPT-6.1 Terra20Use GPT-6 Astra for the most demanding work, GPT-6.1 Sol for complex work at

63 21lower cost, GPT-6.1 Terra for visual reasoning and writing, or GPT-6 Luna for

64GPT-6.1 Terra is a fast, efficient model for visual reasoning, precise computer22focused, high-volume tasks. See [Model selection](https://developers.openai.com/api/docs/guides/model-selection)

65use, and clear, natural writing. Use it to match product photos to catalog23for a comparison.

66entries, compare technical drawings, act on application screens, or draft and

67revise text.

68 

69It supports `none`, `low`, `medium` (default), `high`, `xhigh`, and `max`

70reasoning effort. Start with `medium` and increase it if the improvement in

71quality is worth the added time and tokens.

72 

73When migrating from GPT-5.6 Terra, compare both models on representative images

74and workflows using the same reasoning effort. If your application calls tools

75through Chat Completions, migrate those requests to the Responses API.

76 

77See the [model page](https://developers.openai.com/api/docs/models/gpt-6.1-terra) for specifications and pricing,

78[image inputs](https://developers.openai.com/api/docs/guides/images-vision) for visual analysis, and

79[computer use](https://developers.openai.com/api/docs/guides/tools-computer-use) for acting on screens.

80 24 

81<a id="gpt-6-astra-what-is-new" className="scroll-mt-[110px]"></a>25<a id="gpt-6-astra-what-is-new" className="scroll-mt-[110px]"></a>

82 26 

83## What's new27## What's new

84 28 

85- **Async tool calling:** GPT-6 can continue reasoning, call other tools, or answer independent parts of a request while your application runs a tool. Set `async: true` on a function or custom tool and return its result when ready using the original `call_id`. Your application still executes the tool and manages pending work. See [Async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling) for basic usage and a developer-defined wait-tool pattern.29- **Async tool calling:** Supported models can continue reasoning, call other tools, or answer independent parts of a request while your application runs a tool. Set `async: true` on a function or custom tool and return its result when ready using the original `call_id`. Your application executes the tool and manages pending work. See [Async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling) for compatibility and examples.

86- **Mid-turn steering:** Send additional user instructions while GPT-6 is working, such as a correction or a change in requirements. Over a WebSocket connection, the Responses API preserves completed work and includes the update in a continuation. See [Mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the event flow and tool-result handling.30- **Mid-turn steering:** Send additional user instructions while GPT-6 is working, such as a correction or a change in requirements. Over a WebSocket connection, the Responses API preserves completed work and includes the update in a continuation. See [Mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the event flow and tool-result handling.

87- **Change reasoning mid-conversation while preserving cache:** Add a `configuration_update` input item to increase reasoning effort for difficult work or reduce it for routine follow-ups without rewriting the original prompt prefix. The updated reasoning effort applies until another `configuration_update` input item overrides it. See [Change reasoning mid-conversation](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation) for examples and compatibility.31- **Change reasoning mid-conversation while preserving cache:** Add a `configuration_update` input item to increase reasoning effort for difficult work or reduce it for routine follow-ups without rewriting the original prompt prefix. The updated reasoning effort applies until another `configuration_update` input item overrides it. See [Change reasoning mid-conversation](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation) for examples and compatibility.

32- **Multi-agent and persisted reasoning on GPT-6.1 Sol:** Use the [Responses Multi-agent beta](https://developers.openai.com/api/docs/guides/responses-multi-agent) to delegate work to subagents. Set [`reasoning.context` to `all_turns`](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls) to reuse compatible reasoning from earlier turns.

88- **Misalignment monitoring:** As part of our [strengthened safeguards](https://openai.com/index/path-to-astra/) for GPT-6 Astra, our systems asynchronously monitor for misalignment and trigger alerts when necessary. See [Misalignment monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring) for more information.33- **Misalignment monitoring:** As part of our [strengthened safeguards](https://openai.com/index/path-to-astra/) for GPT-6 Astra, our systems asynchronously monitor for misalignment and trigger alerts when necessary. See [Misalignment monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring) for more information.

89 34 

90GPT-6 also supports the existing API capabilities available with GPT-5.6, including [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs), [streaming](https://developers.openai.com/api/docs/guides/streaming-responses), [Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling), [multi-agent orchestration](https://developers.openai.com/api/docs/guides/responses-multi-agent), [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), [persisted reasoning](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls), [compaction](https://developers.openai.com/api/docs/guides/compaction), and [pro mode](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode).35GPT-6 also supports the existing API capabilities available with GPT-5.6, including [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs), [streaming](https://developers.openai.com/api/docs/guides/streaming-responses), [Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling), [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), [compaction](https://developers.openai.com/api/docs/guides/compaction), and [pro mode](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode).

91 36 

92## Limitations37## Limitations

93 38 


216 161 

217### Update API and model parameters162### Update API and model parameters

218 163 

219Set `model` to `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, or `gpt-6-luna`, then check the following:164Set `model` to `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, or `gpt-6-luna`, then review the compatibility checks below.

165 

166If you're switching from `gpt-6-sol` to `gpt-6.1-sol`, use `low` if your

167current reasoning effort is `none`. Move any Chat Completions requests that

168call functions to the Responses API.

169 

170When moving from GPT-5.6 Terra to GPT-6.1 Terra, compare both models on

171representative images and workflows at the same reasoning effort.

220 172 

221- **Reasoning effort:** Preserve your current effective [reasoning effort](https://developers.openai.com/api/docs/guides/reasoning#reasoning-effort) where supported. GPT-6 Astra and GPT-6.1 Sol do not support `none`; use `low` instead. GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna support `none`. If your existing request uses `minimal`, start with `low` and compare results on representative tasks. Use `reasoning.effort` in Responses or `reasoning_effort` in Chat Completions.173- **Reasoning effort:** Preserve your current effective [reasoning effort](https://developers.openai.com/api/docs/guides/reasoning#reasoning-effort) where supported. GPT-6 Astra and GPT-6.1 Sol do not support `none`; use `low` instead. GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna support `none`. If your existing request uses `minimal`, start with `low` and compare results on representative tasks. Use `reasoning.effort` in Responses or `reasoning_effort` in Chat Completions.

222- **Tool calling:** Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses#migrating-from-chat-completions). GPT-6 Astra, GPT-6.1 Sol, and GPT-6.1 Terra support Chat Completions, but tool calling requires Responses. GPT-6 Sol and GPT-6 Luna support function calling in Chat Completions only with `reasoning_effort: "none"`. Use Responses for reasoning with tools.174- **Tool calling:** Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses#migrating-from-chat-completions). GPT-6 Astra, GPT-6.1 Sol, and GPT-6.1 Terra support Chat Completions, but tool calling requires Responses. GPT-6 Sol and GPT-6 Luna support function calling in Chat Completions only with `reasoning_effort: "none"`. Use Responses for reasoning with tools.

Details

9 9 

10> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.10> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

11 11 

12- [GPT-6 Astra](https://developers.openai.com/api/docs/models/gpt-6-astra)12<a id="gpt-6-astra-gpt-6-astra"></a>

13 

14 **Highest intelligence**

15 

16 For the most demanding reasoning, coding, and professional work.

17 

18- [GPT-6.1 Sol](https://developers.openai.com/api/docs/models/gpt-6.1-sol)

19 

20 **Balanced speed, cost, and intelligence**

21 

22 Near-Astra performance for complex work at a lower cost.

23 

24- [GPT-6.1 Terra](https://developers.openai.com/api/docs/models/gpt-6.1-terra)

25 

26 **Fast and efficient**

27 

28 For visual reasoning, precise computer use, and clear, natural writing.

29 

30- [GPT-6 Luna](https://developers.openai.com/api/docs/models/gpt-6-luna)

31 

32 **Fastest and most cost-effective**

33 

34 Strong performance for focused, high-volume tasks.

35 

36 

37 

38To get started, set `model` in a [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses) request. If you already use [`gpt-6-sol`](https://developers.openai.com/api/docs/models/gpt-6-sol), review the [migration guidance](#migration-quickstart) before switching to GPT-6.1 Sol.

39 

40### GPT-6 Astra

41 

42GPT-6 Astra is our most intelligent model yet, with state-of-the-art performance in computer use, browsing, software engineering, science, and professional work. It can carry out multi-step workflows across code, browsers, and professional software. In [several evaluations](https://openai.com/index/gpt-6-astra/), Astra achieved stronger results using substantially fewer output tokens. Its estimated API cost per task was lower than earlier models despite its higher per-token pricing.

43 

44GPT-6 Astra is also our most aligned model yet. It excels at exercising care, respecting task boundaries, and communicating transparently. When instructions leave room for interpretation, it uses the context it has to fill in routine gaps and asks focused questions when the answer could change the outcome. It incorporates new requirements, changes course when asked, and answers side questions without losing track of the broader task.

45 

46All GPT-6 Astra users also have access to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) and the new [Ultrafast mode](https://developers.openai.com/api/docs/guides/ultrafast-mode) for our fastest API speeds.

47 

48<a id="gpt-61-sol"></a>13<a id="gpt-61-sol"></a>

49<a id="gpt-6.1-sol"></a>14<a id="gpt-6.1-sol"></a>

50 15<a id="gpt-6-astra-gpt-61-sol"></a>

51### GPT-6.1 Sol

52 

53GPT-6.1 Sol delivers near-Astra performance at a lower cost for complex coding,

54computer use, and professional work. It supports `low`, `medium` (default),

55`high`, `xhigh`, and `max` reasoning effort.

56 

57See the [model page](https://developers.openai.com/api/docs/models/gpt-6.1-sol) for specifications and pricing.

58 

59<a id="gpt-61-terra"></a>16<a id="gpt-61-terra"></a>

60<a id="gpt-6.1-terra"></a>17<a id="gpt-6.1-terra"></a>

18<a id="gpt-6-astra-gpt-61-terra"></a>

61 19 

62### GPT-6.1 Terra20Use GPT-6 Astra for the most demanding work, GPT-6.1 Sol for complex work at

63 21lower cost, GPT-6.1 Terra for visual reasoning and writing, or GPT-6 Luna for

64GPT-6.1 Terra is a fast, efficient model for visual reasoning, precise computer22focused, high-volume tasks. See [Model selection](https://developers.openai.com/api/docs/guides/model-selection)

65use, and clear, natural writing. Use it to match product photos to catalog23for a comparison.

66entries, compare technical drawings, act on application screens, or draft and

67revise text.

68 

69It supports `none`, `low`, `medium` (default), `high`, `xhigh`, and `max`

70reasoning effort. Start with `medium` and increase it if the improvement in

71quality is worth the added time and tokens.

72 

73When migrating from GPT-5.6 Terra, compare both models on representative images

74and workflows using the same reasoning effort. If your application calls tools

75through Chat Completions, migrate those requests to the Responses API.

76 

77See the [model page](https://developers.openai.com/api/docs/models/gpt-6.1-terra) for specifications and pricing,

78[image inputs](https://developers.openai.com/api/docs/guides/images-vision) for visual analysis, and

79[computer use](https://developers.openai.com/api/docs/guides/tools-computer-use) for acting on screens.

80 24 

81<a id="gpt-6-astra-what-is-new" className="scroll-mt-[110px]"></a>25<a id="gpt-6-astra-what-is-new" className="scroll-mt-[110px]"></a>

82 26 

83## What's new27## What's new

84 28 

85- **Async tool calling:** GPT-6 can continue reasoning, call other tools, or answer independent parts of a request while your application runs a tool. Set `async: true` on a function or custom tool and return its result when ready using the original `call_id`. Your application still executes the tool and manages pending work. See [Async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling) for basic usage and a developer-defined wait-tool pattern.29- **Async tool calling:** Supported models can continue reasoning, call other tools, or answer independent parts of a request while your application runs a tool. Set `async: true` on a function or custom tool and return its result when ready using the original `call_id`. Your application executes the tool and manages pending work. See [Async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling) for compatibility and examples.

86- **Mid-turn steering:** Send additional user instructions while GPT-6 is working, such as a correction or a change in requirements. Over a WebSocket connection, the Responses API preserves completed work and includes the update in a continuation. See [Mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the event flow and tool-result handling.30- **Mid-turn steering:** Send additional user instructions while GPT-6 is working, such as a correction or a change in requirements. Over a WebSocket connection, the Responses API preserves completed work and includes the update in a continuation. See [Mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the event flow and tool-result handling.

87- **Change reasoning mid-conversation while preserving cache:** Add a `configuration_update` input item to increase reasoning effort for difficult work or reduce it for routine follow-ups without rewriting the original prompt prefix. The updated reasoning effort applies until another `configuration_update` input item overrides it. See [Change reasoning mid-conversation](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation) for examples and compatibility.31- **Change reasoning mid-conversation while preserving cache:** Add a `configuration_update` input item to increase reasoning effort for difficult work or reduce it for routine follow-ups without rewriting the original prompt prefix. The updated reasoning effort applies until another `configuration_update` input item overrides it. See [Change reasoning mid-conversation](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation) for examples and compatibility.

32- **Multi-agent and persisted reasoning on GPT-6.1 Sol:** Use the [Responses Multi-agent beta](https://developers.openai.com/api/docs/guides/responses-multi-agent) to delegate work to subagents. Set [`reasoning.context` to `all_turns`](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls) to reuse compatible reasoning from earlier turns.

88- **Misalignment monitoring:** As part of our [strengthened safeguards](https://openai.com/index/path-to-astra/) for GPT-6 Astra, our systems asynchronously monitor for misalignment and trigger alerts when necessary. See [Misalignment monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring) for more information.33- **Misalignment monitoring:** As part of our [strengthened safeguards](https://openai.com/index/path-to-astra/) for GPT-6 Astra, our systems asynchronously monitor for misalignment and trigger alerts when necessary. See [Misalignment monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring) for more information.

89 34 

90GPT-6 also supports the existing API capabilities available with GPT-5.6, including [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs), [streaming](https://developers.openai.com/api/docs/guides/streaming-responses), [Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling), [multi-agent orchestration](https://developers.openai.com/api/docs/guides/responses-multi-agent), [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), [persisted reasoning](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls), [compaction](https://developers.openai.com/api/docs/guides/compaction), and [pro mode](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode).35GPT-6 also supports the existing API capabilities available with GPT-5.6, including [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs), [streaming](https://developers.openai.com/api/docs/guides/streaming-responses), [Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling), [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), [compaction](https://developers.openai.com/api/docs/guides/compaction), and [pro mode](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode).

91 36 

92## Limitations37## Limitations

93 38 


216 161 

217### Update API and model parameters162### Update API and model parameters

218 163 

219Set `model` to `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, or `gpt-6-luna`, then check the following:164Set `model` to `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, or `gpt-6-luna`, then review the compatibility checks below.

165 

166If you're switching from `gpt-6-sol` to `gpt-6.1-sol`, use `low` if your

167current reasoning effort is `none`. Move any Chat Completions requests that

168call functions to the Responses API.

169 

170When moving from GPT-5.6 Terra to GPT-6.1 Terra, compare both models on

171representative images and workflows at the same reasoning effort.

220 172 

221- **Reasoning effort:** Preserve your current effective [reasoning effort](https://developers.openai.com/api/docs/guides/reasoning#reasoning-effort) where supported. GPT-6 Astra and GPT-6.1 Sol do not support `none`; use `low` instead. GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna support `none`. If your existing request uses `minimal`, start with `low` and compare results on representative tasks. Use `reasoning.effort` in Responses or `reasoning_effort` in Chat Completions.173- **Reasoning effort:** Preserve your current effective [reasoning effort](https://developers.openai.com/api/docs/guides/reasoning#reasoning-effort) where supported. GPT-6 Astra and GPT-6.1 Sol do not support `none`; use `low` instead. GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna support `none`. If your existing request uses `minimal`, start with `low` and compare results on representative tasks. Use `reasoning.effort` in Responses or `reasoning_effort` in Chat Completions.

222- **Tool calling:** Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses#migrating-from-chat-completions). GPT-6 Astra, GPT-6.1 Sol, and GPT-6.1 Terra support Chat Completions, but tool calling requires Responses. GPT-6 Sol and GPT-6 Luna support function calling in Chat Completions only with `reasoning_effort: "none"`. Use Responses for reasoning with tools.174- **Tool calling:** Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses#migrating-from-chat-completions). GPT-6 Astra, GPT-6.1 Sol, and GPT-6.1 Terra support Chat Completions, but tool calling requires Responses. GPT-6 Sol and GPT-6 Luna support function calling in Chat Completions only with `reasoning_effort: "none"`. Use Responses for reasoning with tools.

Details

30## Auditing your integration for prefix changes30## Auditing your integration for prefix changes

31 31 

32Use [Prompt Cache Diagnostics](https://developers.openai.com/api/docs/guides/prompt-caching/diagnostics) to see when cache misses occur and investigate prefix changes. Compare a request with an earlier response by setting `prompt_cache_options.comparison_response_id` to the earlier response ID, then inspect the diagnostic reason and cached token count. Use this information to reduce prefix changes in your integration. Diagnostics report the first identified difference on a best-effort basis; they can’t verify whether the model reused reasoning.32Use [Prompt Cache Diagnostics](https://developers.openai.com/api/docs/guides/prompt-caching/diagnostics) to see when cache misses occur and investigate prefix changes. Compare a request with an earlier response by setting `prompt_cache_options.comparison_response_id` to the earlier response ID, then inspect the diagnostic reason and cached token count. Use this information to reduce prefix changes in your integration. Diagnostics report the first identified difference on a best-effort basis; they can’t verify whether the model reused reasoning.

33 

34Use `input_transformations` from the Responses API response to see which reasoning items the API removed from the input and why. To investigate a `prefix_mismatch` reasoning removal, you can match the `id` to a reasoning item in an earlier response’s `output`. If your integration modified an earlier input, you can make updates recommended above to preserve the reasoning.

Details

9 9 

10> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.10> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

11 11 

12- [GPT-6 Astra](https://developers.openai.com/api/docs/models/gpt-6-astra)12<a id="gpt-6-astra-gpt-6-astra"></a>

13 

14 **Highest intelligence**

15 

16 For the most demanding reasoning, coding, and professional work.

17 

18- [GPT-6.1 Sol](https://developers.openai.com/api/docs/models/gpt-6.1-sol)

19 

20 **Balanced speed, cost, and intelligence**

21 

22 Near-Astra performance for complex work at a lower cost.

23 

24- [GPT-6.1 Terra](https://developers.openai.com/api/docs/models/gpt-6.1-terra)

25 

26 **Fast and efficient**

27 

28 For visual reasoning, precise computer use, and clear, natural writing.

29 

30- [GPT-6 Luna](https://developers.openai.com/api/docs/models/gpt-6-luna)

31 

32 **Fastest and most cost-effective**

33 

34 Strong performance for focused, high-volume tasks.

35 

36 

37 

38To get started, set `model` in a [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses) request. If you already use [`gpt-6-sol`](https://developers.openai.com/api/docs/models/gpt-6-sol), review the [migration guidance](#migration-quickstart) before switching to GPT-6.1 Sol.

39 

40### GPT-6 Astra

41 

42GPT-6 Astra is our most intelligent model yet, with state-of-the-art performance in computer use, browsing, software engineering, science, and professional work. It can carry out multi-step workflows across code, browsers, and professional software. In [several evaluations](https://openai.com/index/gpt-6-astra/), Astra achieved stronger results using substantially fewer output tokens. Its estimated API cost per task was lower than earlier models despite its higher per-token pricing.

43 

44GPT-6 Astra is also our most aligned model yet. It excels at exercising care, respecting task boundaries, and communicating transparently. When instructions leave room for interpretation, it uses the context it has to fill in routine gaps and asks focused questions when the answer could change the outcome. It incorporates new requirements, changes course when asked, and answers side questions without losing track of the broader task.

45 

46All GPT-6 Astra users also have access to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) and the new [Ultrafast mode](https://developers.openai.com/api/docs/guides/ultrafast-mode) for our fastest API speeds.

47 

48<a id="gpt-61-sol"></a>13<a id="gpt-61-sol"></a>

49<a id="gpt-6.1-sol"></a>14<a id="gpt-6.1-sol"></a>

50 15<a id="gpt-6-astra-gpt-61-sol"></a>

51### GPT-6.1 Sol

52 

53GPT-6.1 Sol delivers near-Astra performance at a lower cost for complex coding,

54computer use, and professional work. It supports `low`, `medium` (default),

55`high`, `xhigh`, and `max` reasoning effort.

56 

57See the [model page](https://developers.openai.com/api/docs/models/gpt-6.1-sol) for specifications and pricing.

58 

59<a id="gpt-61-terra"></a>16<a id="gpt-61-terra"></a>

60<a id="gpt-6.1-terra"></a>17<a id="gpt-6.1-terra"></a>

18<a id="gpt-6-astra-gpt-61-terra"></a>

61 19 

62### GPT-6.1 Terra20Use GPT-6 Astra for the most demanding work, GPT-6.1 Sol for complex work at

63 21lower cost, GPT-6.1 Terra for visual reasoning and writing, or GPT-6 Luna for

64GPT-6.1 Terra is a fast, efficient model for visual reasoning, precise computer22focused, high-volume tasks. See [Model selection](https://developers.openai.com/api/docs/guides/model-selection)

65use, and clear, natural writing. Use it to match product photos to catalog23for a comparison.

66entries, compare technical drawings, act on application screens, or draft and

67revise text.

68 

69It supports `none`, `low`, `medium` (default), `high`, `xhigh`, and `max`

70reasoning effort. Start with `medium` and increase it if the improvement in

71quality is worth the added time and tokens.

72 

73When migrating from GPT-5.6 Terra, compare both models on representative images

74and workflows using the same reasoning effort. If your application calls tools

75through Chat Completions, migrate those requests to the Responses API.

76 

77See the [model page](https://developers.openai.com/api/docs/models/gpt-6.1-terra) for specifications and pricing,

78[image inputs](https://developers.openai.com/api/docs/guides/images-vision) for visual analysis, and

79[computer use](https://developers.openai.com/api/docs/guides/tools-computer-use) for acting on screens.

80 24 

81<a id="gpt-6-astra-what-is-new" className="scroll-mt-[110px]"></a>25<a id="gpt-6-astra-what-is-new" className="scroll-mt-[110px]"></a>

82 26 

83## What's new27## What's new

84 28 

85- **Async tool calling:** GPT-6 can continue reasoning, call other tools, or answer independent parts of a request while your application runs a tool. Set `async: true` on a function or custom tool and return its result when ready using the original `call_id`. Your application still executes the tool and manages pending work. See [Async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling) for basic usage and a developer-defined wait-tool pattern.29- **Async tool calling:** Supported models can continue reasoning, call other tools, or answer independent parts of a request while your application runs a tool. Set `async: true` on a function or custom tool and return its result when ready using the original `call_id`. Your application executes the tool and manages pending work. See [Async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling) for compatibility and examples.

86- **Mid-turn steering:** Send additional user instructions while GPT-6 is working, such as a correction or a change in requirements. Over a WebSocket connection, the Responses API preserves completed work and includes the update in a continuation. See [Mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the event flow and tool-result handling.30- **Mid-turn steering:** Send additional user instructions while GPT-6 is working, such as a correction or a change in requirements. Over a WebSocket connection, the Responses API preserves completed work and includes the update in a continuation. See [Mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the event flow and tool-result handling.

87- **Change reasoning mid-conversation while preserving cache:** Add a `configuration_update` input item to increase reasoning effort for difficult work or reduce it for routine follow-ups without rewriting the original prompt prefix. The updated reasoning effort applies until another `configuration_update` input item overrides it. See [Change reasoning mid-conversation](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation) for examples and compatibility.31- **Change reasoning mid-conversation while preserving cache:** Add a `configuration_update` input item to increase reasoning effort for difficult work or reduce it for routine follow-ups without rewriting the original prompt prefix. The updated reasoning effort applies until another `configuration_update` input item overrides it. See [Change reasoning mid-conversation](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation) for examples and compatibility.

32- **Multi-agent and persisted reasoning on GPT-6.1 Sol:** Use the [Responses Multi-agent beta](https://developers.openai.com/api/docs/guides/responses-multi-agent) to delegate work to subagents. Set [`reasoning.context` to `all_turns`](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls) to reuse compatible reasoning from earlier turns.

88- **Misalignment monitoring:** As part of our [strengthened safeguards](https://openai.com/index/path-to-astra/) for GPT-6 Astra, our systems asynchronously monitor for misalignment and trigger alerts when necessary. See [Misalignment monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring) for more information.33- **Misalignment monitoring:** As part of our [strengthened safeguards](https://openai.com/index/path-to-astra/) for GPT-6 Astra, our systems asynchronously monitor for misalignment and trigger alerts when necessary. See [Misalignment monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring) for more information.

89 34 

90GPT-6 also supports the existing API capabilities available with GPT-5.6, including [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs), [streaming](https://developers.openai.com/api/docs/guides/streaming-responses), [Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling), [multi-agent orchestration](https://developers.openai.com/api/docs/guides/responses-multi-agent), [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), [persisted reasoning](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls), [compaction](https://developers.openai.com/api/docs/guides/compaction), and [pro mode](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode).35GPT-6 also supports the existing API capabilities available with GPT-5.6, including [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs), [streaming](https://developers.openai.com/api/docs/guides/streaming-responses), [Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling), [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), [compaction](https://developers.openai.com/api/docs/guides/compaction), and [pro mode](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode).

91 36 

92## Limitations37## Limitations

93 38 


216 161 

217### Update API and model parameters162### Update API and model parameters

218 163 

219Set `model` to `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, or `gpt-6-luna`, then check the following:164Set `model` to `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, or `gpt-6-luna`, then review the compatibility checks below.

165 

166If you're switching from `gpt-6-sol` to `gpt-6.1-sol`, use `low` if your

167current reasoning effort is `none`. Move any Chat Completions requests that

168call functions to the Responses API.

169 

170When moving from GPT-5.6 Terra to GPT-6.1 Terra, compare both models on

171representative images and workflows at the same reasoning effort.

220 172 

221- **Reasoning effort:** Preserve your current effective [reasoning effort](https://developers.openai.com/api/docs/guides/reasoning#reasoning-effort) where supported. GPT-6 Astra and GPT-6.1 Sol do not support `none`; use `low` instead. GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna support `none`. If your existing request uses `minimal`, start with `low` and compare results on representative tasks. Use `reasoning.effort` in Responses or `reasoning_effort` in Chat Completions.173- **Reasoning effort:** Preserve your current effective [reasoning effort](https://developers.openai.com/api/docs/guides/reasoning#reasoning-effort) where supported. GPT-6 Astra and GPT-6.1 Sol do not support `none`; use `low` instead. GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna support `none`. If your existing request uses `minimal`, start with `low` and compare results on representative tasks. Use `reasoning.effort` in Responses or `reasoning_effort` in Chat Completions.

222- **Tool calling:** Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses#migrating-from-chat-completions). GPT-6 Astra, GPT-6.1 Sol, and GPT-6.1 Terra support Chat Completions, but tool calling requires Responses. GPT-6 Sol and GPT-6 Luna support function calling in Chat Completions only with `reasoning_effort: "none"`. Use Responses for reasoning with tools.174- **Tool calling:** Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses#migrating-from-chat-completions). GPT-6 Astra, GPT-6.1 Sol, and GPT-6.1 Terra support Chat Completions, but tool calling requires Responses. GPT-6 Sol and GPT-6 Luna support function calling in Chat Completions only with `reasoning_effort: "none"`. Use Responses for reasoning with tools.

Details

1719 1719 

1720### Attributes1720### Attributes

1721 1721 

1722Each `vector_store.file` can have associated `attributes`, a dictionary of values that can be referenced when performing [semantic search](#semantic-search) with [attribute filtering](#attribute-filtering). The dictionary can have at most 16 keys, with a limit of 256 characters each.1722Each `vector_store.file` can have associated `attributes`, a dictionary of values that can be referenced when performing [semantic search](#semantic-search) with [attribute filtering](#attribute-filtering). The dictionary can have at most 16 keys. Keys can contain up to 64 characters, and string values can contain up to 512 characters.

1723 1723 

1724Create vector store file with attributes1724Create vector store file with attributes

1725 1725 

Details

14 specialized examples below document compatibility for existing integrations14 specialized examples below document compatibility for existing integrations

15 until shutdown.15 until shutdown.

16 16 

17Files can be up to 25 MB. Supported input formats are `mp3`, `mp4`, `mpeg`, `mpga`, `m4a`, `wav`, and `webm`.17Files can be up to 25 MB. Supported input formats include `flac`, `mp3`, `mp4`, `mpeg`, `mpga`, `m4a`, `ogg`, `wav`, and `webm`.

18 18 

19For audio that is still arriving from a microphone, call, or media stream, use19For audio that is still arriving from a microphone, call, or media stream, use

20 [Realtime transcription](https://developers.openai.com/api/docs/guides/realtime-transcription).20 [Realtime transcription](https://developers.openai.com/api/docs/guides/realtime-transcription).

Details

4 4 

5JSON is one of the most widely used formats in the world for applications to exchange data.5JSON is one of the most widely used formats in the world for applications to exchange data.

6 6 

7Structured Outputs is a feature that ensures the model will always generate responses that adhere to your supplied [JSON Schema](https://json-schema.org/overview/what-is-jsonschema), so you don't need to worry about the model omitting a required key, or hallucinating an invalid enum value.7Structured Outputs constrains completed, non-refusal model output to your supplied [JSON Schema](https://json-schema.org/overview/what-is-jsonschema). Your application still needs to handle refusals, incomplete responses, and API errors, and validate any business rules that the schema does not express.

8 8 

9Some benefits of Structured Outputs include:9Some benefits of Structured Outputs include:

10 10 

111. **Reliable type-safety:** No need to validate or retry incorrectly formatted responses111. **Schema adherence:** Required fields and enum values follow the supported JSON Schema you supply

121. **Explicit refusals:** Safety-based model refusals are now programmatically detectable121. **Explicit refusals:** Safety-based model refusals are now programmatically detectable

131. **Simpler prompting:** No need for strongly worded prompts to achieve consistent formatting131. **Simpler prompting:** No need for strongly worded prompts to achieve consistent formatting

14 14 

15In addition to supporting JSON Schema in the REST API, the OpenAI libraries for [Python](https://github.com/openai/openai-python/blob/main/helpers.md#structured-outputs-parsing-helpers) and [JavaScript](https://github.com/openai/openai-node/blob/master/helpers.md#structured-outputs-parsing-helpers) also let you define object schemas using [`pydantic.BaseModel`](https://docs.pydantic.dev/latest/) and [`z.object`](https://zod.dev/) respectively. Below, you can see how to extract information from unstructured text that conforms to a schema defined in code.15In addition to supporting JSON Schema in the REST API, the OpenAI libraries for [Python](https://github.com/openai/openai-python/blob/main/helpers.md#structured-outputs-parsing-helpers) and [JavaScript](https://github.com/openai/openai-node/blob/main/docs/structured-outputs.md) also let you define object schemas using [`pydantic.BaseModel`](https://docs.pydantic.dev/latest/) and [`z.object`](https://zod.dev/) respectively. Below, you can see how to extract information from unstructured text that conforms to a schema defined in code.

16 16 

17The Ruby SDK supports schemas defined with Sorbet `T::Struct` and returns typed parsed results.17The Ruby SDK supports schemas defined with Sorbet `T::Struct` and returns typed parsed results.

18 18 


3719 print(event.delta, end="")3719 print(event.delta, end="")

3720 elif event.type == "response.output_text.delta":3720 elif event.type == "response.output_text.delta":

3721 print(event.delta, end="")3721 print(event.delta, end="")

3722 elif event.type == "response.error":3722 elif event.type == "error":

3723 print(event.error, end="")3723 raise RuntimeError(event.message)

3724 elif event.type in ("response.failed", "response.incomplete"):

3725 response = event.response

3726 message = f"Response {response.status}"

3727 if response.error and response.error.message:

3728 message += f": {response.error.message}"

3729 elif response.incomplete_details and response.incomplete_details.reason:

3730 message += f": {response.incomplete_details.reason}"

3731 raise RuntimeError(message)

3724 elif event.type == "response.completed":3732 elif event.type == "response.completed":

3725 print("Completed") # print(event.response.output)3733 print("Completed") # print(event.response.output)

3726 3734 

Details

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) 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 

Details

33 33 

34Use the session ID unchanged, including its prefix, and verify that your application has authorized access to that session.34Use the session ID unchanged, including its prefix, and verify that your application has authorized access to that session.

35 35 

36### Replay on attachment

37 

38Each time you attach, the sideband first replays events from the preceding 3 seconds, then continues with new events. This window applies to conversation events, call-progress events, and reflected input and output audio. Events older than 3 seconds are not replayed, so attach promptly and keep any earlier history your application needs.

39 

40Replayed events retain their original `event_id` when present. Deduplicate those events by `event_id`, especially after reconnecting, to avoid repeating tool execution or other actions. Reflected audio events do not have an `event_id`; see [Receive reflected audio](#receive-reflected-audio) for their timing fields.

41 

36### Observe events and send commands42### Observe events and send commands

37 43 

38| Task | Events or commands |44| Task | Events or commands |


50 56 

51### Receive reflected audio57### Receive reflected audio

52 58 

53A sideband also receives copies of subsequent input and output audio while the primary connection carries the live media:59A sideband receives copies of input and output audio, including audio in the replay window, while the primary connection carries the live media:

54 60 

55| Event | Audio field | Timing |61| Event | Audio field | Timing |

56| ---------------------------- | ----------- | ---------------------------------------------------------------------------- |62| ---------------------------- | ----------- | ---------------------------------------------------------------------------- |

Details

171| `transport.answered` | The call has been answered and media is established. |171| `transport.answered` | The call has been answered and media is established. |

172| `transport.failed` | Call setup failed after session initialization. Inspect `error.code` and `error.message`. |172| `transport.failed` | Call setup failed after session initialization. Inspect `error.code` and `error.message`. |

173 173 

174Each call-progress event includes `event_id` and `session_id`. Attach immediately after creation: the sideband only replays events from the preceding 3 seconds, so a later attachment can miss earlier call progress. Replayed events retain their original event IDs. Deduplicate events by `event_id`.174Each call-progress event includes `event_id` and `session_id`. Attach immediately after creation: the sideband first replays events from the preceding 3 seconds, then continues with new events, so a later attachment can miss earlier call progress. This replay window also applies to conversation events and reflected audio. Replayed call-progress events retain their original event IDs. Deduplicate them by `event_id`. See [Replay on attachment](https://developers.openai.com/api/docs/guides/voice-server-controls?api=live#replay-on-attachment) for details.

175 175 

176Once connected, use the [active call controls](#manage-an-active-call) to send keypad tones, transfer the call, or hang up. Keep the sideband open for `session.closed` and final usage as described in [Usage and graceful close](https://developers.openai.com/api/docs/guides/live-conversations#usage-and-graceful-close).176Once connected, use the [active call controls](#manage-an-active-call) to send keypad tones, transfer the call, or hang up. Keep the sideband open for `session.closed` and final usage as described in [Usage and graceful close](https://developers.openai.com/api/docs/guides/live-conversations#usage-and-graceful-close).

177 177 

libraries.md +2 −2

Details

169 169 

170 170

171 171 

172OpenAI provides an API helper for the Java programming language, currently in beta. You can include the Maven dependency using the following configuration:172OpenAI provides an API helper for the Java programming language. You can include the Maven dependency using the following configuration:

173 173 

174```xml174```xml

175<dependency>175<dependency>


181 181 

182 182 

183 183 

184A simple API request to [Responses API](https://developers.openai.com/api/reference/resources/responses) would look like this:184An API request to the [Responses API](https://developers.openai.com/api/reference/resources/responses) looks like this:

185 185 

186Test a basic API request186Test a basic API request

187 187 

quickstart.md +2 −2

Details

179 179 

180 180

181 181 

182OpenAI provides an API helper for the Java programming language, currently in beta. You can include the Maven dependency using the following configuration:182OpenAI provides an API helper for the Java programming language. You can include the Maven dependency using the following configuration:

183 183 

184```xml184```xml

185<dependency>185<dependency>


191 191 

192 192 

193 193 

194A simple API request to [Responses API](https://developers.openai.com/api/reference/resources/responses) would look like this:194An API request to the [Responses API](https://developers.openai.com/api/reference/resources/responses) looks like this:

195 195 

196Test a basic API request196Test a basic API request

197 197 

Details

126The `crawl` function is the final step in the web scraping task setup. It keeps track of the visited URLs to avoid repeating the same page, which might be linked across multiple pages on a site. It also extracts the raw text from a page without the HTML tags, and writes the text content into a local .txt file specific to the page.126The `crawl` function is the final step in the web scraping task setup. It keeps track of the visited URLs to avoid repeating the same page, which might be linked across multiple pages on a site. It also extracts the raw text from a page without the HTML tags, and writes the text content into a local .txt file specific to the page.

127 127 

128```python128```python

129from hashlib import sha256

130 

131 

129def crawl(url):132def crawl(url):

130 # Parse the URL and get the domain133 # Parse the URL and get the domain

131 parsed = urlparse(url)134 parsed = urlparse(url)


156 print(url) # for debugging and to see the progress159 print(url) # for debugging and to see the progress

157 160 

158 # Save text from the url to a <url>.txt file161 # Save text from the url to a <url>.txt file

159 page_name = (local_domain + urlparse(url).path).replace("/", "_")162 parsed_page = urlparse(url)

163 page_name = (local_domain + parsed_page.path).replace("/", "_")

164 if parsed_page.query:

165 # Parsed URL domains and paths cannot contain the fragment separator '#'.

166 suffix = "#" + sha256(url.encode("utf-8")).hexdigest()

167 # Keep the filename, including its extension, within 255 bytes.

168 prefix_bytes = 255 - len(suffix) - len(".txt")

169 name_prefix = page_name.encode("utf-8")[:prefix_bytes]

170 page_name = name_prefix.decode("utf-8", errors="ignore") + suffix

160 with open(171 with open(

161 "text/" + local_domain + "/" + page_name + ".txt",172 "text/" + local_domain + "/" + page_name + ".txt",

162 "w",173 "w",