Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

openai-sdk changedcli-sdks-libraries/libraries/openai-sdk

Nearest release: v2.1.251, published 2 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+169added
Lines−6removed
From line 33 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits13to this page, all time

The whole hunk

from line 33, old and new numbered
/
lines
from line 33
3333 
3434### Quick start example
3535 
36<CodeGroup>
36<CodeGroup exclude="shell">
3737 ```python Python
3838 import os
3939 
from line 59
5959 import OpenAI from "openai";
6060 
6161 const openai = new OpenAI({
62 apiKey: "ANTHROPIC_API_KEY", // Your Claude API key
62 apiKey: process.env.ANTHROPIC_API_KEY, // Your Claude API key
6363 baseURL: "https://api.anthropic.com/v1/" // Claude API endpoint
6464 });
6565 
6666 const response = await openai.chat.completions.create({
67 messages: [{ role: "user", content: "Who are you?" }],
67 messages: [
68 { role: "system", content: "You are a helpful assistant." },
69 { role: "user", content: "Who are you?" }
70 ],
6871 model: "claude-opus-5" // Claude model name
6972 });
7073 
7174 console.log(response.choices[0].message.content);
7275 ```
76 
77 ```csharp C#
78 using System.ClientModel;
79 using OpenAI;
80 using OpenAI.Chat;
81 
82 ChatClient chatClient = new(
83 model: "claude-opus-5", // Claude model name
84 credential: new ApiKeyCredential(
85 Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY")), // Your Claude API key
86 options: new OpenAIClientOptions()
87 {
88 Endpoint = new Uri("https://api.anthropic.com/v1/") // the Claude API endpoint
89 });
90 
91 ChatCompletion completion = chatClient.CompleteChat(
92 new SystemChatMessage("You are a helpful assistant."),
93 new UserChatMessage("Who are you?"));
94 
95 Console.WriteLine(completion.Content[0].Text);
96 ```
97 
98 ```go Go
99 package main
100 
101 import (
102 "context"
103 "fmt"
104 "os"
105 
106 "github.com/openai/openai-go/v3"
107 "github.com/openai/openai-go/v3/option"
108 )
109 
110 func main() {
111 client := openai.NewClient(
112 option.WithAPIKey(os.Getenv("ANTHROPIC_API_KEY")), // Your Claude API key
113 option.WithBaseURL("https://api.anthropic.com/v1/"), // the Claude API endpoint
114 )
115 
116 response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
117 Model: "claude-opus-5", // Claude model name
118 Messages: []openai.ChatCompletionMessageParamUnion{
119 openai.SystemMessage("You are a helpful assistant."),
120 openai.UserMessage("Who are you?"),
121 },
122 })
123 if err != nil {
124 panic(err)
125 }
126 
127 fmt.Println(response.Choices[0].Message.Content)
128 }
129 ```
130 
131 ```java Java
132 import com.openai.client.OpenAIClient;
133 import com.openai.client.okhttp.OpenAIOkHttpClient;
134 import com.openai.models.chat.completions.ChatCompletion;
135 import com.openai.models.chat.completions.ChatCompletionCreateParams;
136 
137 public class QuickStart {
138 public static void main(String[] args) {
139 OpenAIClient client = OpenAIOkHttpClient.builder()
140 .apiKey(System.getenv("ANTHROPIC_API_KEY")) // Your Claude API key
141 .baseUrl("https://api.anthropic.com/v1/") // the Claude API endpoint
142 .build();
143 
144 ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
145 .model("claude-opus-5") // Claude model name
146 .addSystemMessage("You are a helpful assistant.")
147 .addUserMessage("Who are you?")
148 .build();
149 
150 ChatCompletion completion = client.chat().completions().create(params);
151 System.out.println(completion.choices().get(0).message().content().orElse(""));
152 }
153 }
154 ```
155 
156 ```php PHP
157 <?php
158 // There is no official OpenAI PHP SDK, so no example is shown here.
159 // To use Claude from PHP, use the native Claude API instead:
160 // https://platform.claude.com/docs/en/cli-sdks-libraries/overview
161 ```
162 
163 ```ruby Ruby
164 require "openai"
165 
166 openai = OpenAI::Client.new(
167 api_key: ENV["ANTHROPIC_API_KEY"], # Your Claude API key
168 base_url: "https://api.anthropic.com/v1/" # the Claude API endpoint
169 )
170 
171 response = openai.chat.completions.create(
172 model: "claude-opus-5", # Claude model name
173 messages: [
174 {role: "system", content: "You are a helpful assistant."},
175 {role: "user", content: "Who are you?"}
176 ]
177 )
178 
179 puts response.choices.first.message.content
180 ```
73181</CodeGroup>
74182 
75183## Important OpenAI compatibility limitations
from line 203
95203 
96204### Thinking support
97205 
98You can enable [thinking](https://platform.claude.com/docs/en/build-with-claude/thinking) by adding the `thinking` parameter. On current models thinking is adaptive, with Claude deciding when and how deeply to think, and on Claude 5 models it is on by default; manually configured extended thinking is a legacy mode. While thinking improves Claude's reasoning for complex tasks, the OpenAI SDK doesn't return Claude's detailed thought process. For full thinking features, including access to Claude's step-by-step reasoning output, use the native Claude API.
206You can enable [thinking](https://platform.claude.com/docs/en/build-with-claude/thinking) by adding the `thinking` parameter. On current models thinking is adaptive, with Claude deciding when and how deeply to think, and on Claude 5 models it is on by default; manually configured extended thinking is a legacy mode. Although thinking improves Claude's reasoning for complex tasks, the OpenAI SDK doesn't return Claude's detailed thought process. For full thinking features, including access to Claude's step-by-step reasoning output, use the native Claude API.
99207 
100<CodeGroup>
208<CodeGroup exclude="shell">
101209 ```python Python
102210 response = client.chat.completions.create(
103211 model="claude-sonnet-4-6",
from line 221
113221 // @ts-expect-error
114222 thinking: { type: "enabled", budget_tokens: 2000 }
115223 });
224 ```
225 
226 ```csharp C#
227 // The .NET SDK has no extra_body parameter like Python's, so this example
228 // sends the thinking parameter with the SDK's documented protocol method
229 // (a raw JSON request body).
230 BinaryData input = BinaryData.FromString("""
231 {
232 "model": "claude-sonnet-4-6",
233 "messages": [{ "role": "user", "content": "Who are you?" }],
234 "thinking": { "type": "enabled", "budget_tokens": 2000 }
235 }
236 """);
237 
238 using BinaryContent content = BinaryContent.Create(input);
239 ClientResult result = chatClient.CompleteChat(content);
240 ```
241 
242 ```go Go
243 response, err := client.Chat.Completions.New(
244 context.Background(),
245 openai.ChatCompletionNewParams{
246 Model: "claude-sonnet-4-6",
247 Messages: []openai.ChatCompletionMessageParamUnion{
248 openai.UserMessage("Who are you?"),
249 },
250 },
251 option.WithJSONSet("thinking", map[string]any{"type": "enabled", "budget_tokens": 2000}),
252 )
253 ```
254 
255 ```java Java
256 ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
257 .model("claude-sonnet-4-6")
258 .addUserMessage("Who are you?")
259 .putAdditionalBodyProperty("thinking",
260 JsonValue.from(Map.of("type", "enabled", "budget_tokens", 2000)))
261 .build();
262 
263 ChatCompletion completion = client.chat().completions().create(params);
264 ```
265 
266 ```php PHP
267 <?php
268 // There is no official OpenAI PHP SDK, so no example is shown here.
269 // To use Claude from PHP, use the native Claude API instead:
270 // https://platform.claude.com/docs/en/cli-sdks-libraries/overview
271 ```
272 
273 ```ruby Ruby
274 response = openai.chat.completions.create(
275 model: "claude-sonnet-4-6",
276 messages: [{role: "user", content: "Who are you?"}],
277 request_options: {extra_body: {thinking: {type: "enabled", budget_tokens: 2000}}}
278 )
116279 ```
117280</CodeGroup>
118281 
Feedback