OpenAI API Supported Programming Languages and SDKs (2026)
Which programming languages does the OpenAI API support?
Any language that can send an HTTPS request with a JSON body can call the OpenAI API. The API is a plain REST interface, so the real question is which languages have an official SDK. As of December 1, 2026, OpenAI's SDKs and CLI page lists six official libraries:
|
Language |
Package |
Install |
Minimum runtime |
Repository |
|---|---|---|---|---|
|
Python |
|
|
Python 3.10+ |
|
|
TypeScript / JavaScript |
|
|
Node.js 22+ (also Deno, Bun) |
|
|
C# / .NET |
|
|
.NET Standard 2.0 |
|
|
Java |
|
Maven / Gradle dependency |
Java 8+ |
|
|
Go |
|
|
Go 1.26+ for the current release |
|
|
Ruby |
|
|
Ruby 3.3.0+ |
On top of these, OpenAI ships an openai command-line tool (installable with Homebrew) for shell scripts, and the Agents SDK for Python and TypeScript if you need agent orchestration rather than direct API calls.
Runtime minimums come from each repository's README and move over time; check the README before you pin a version. The .NET library is built in collaboration with Microsoft, and the Go README notes that older Go versions must pin older SDK releases.
Official SDK vs community library vs raw HTTP
Three tiers exist, and they come with different guarantees:
- Official SDKs (the six above). Maintained by OpenAI, generated from the OpenAPI spec, updated when new endpoints ship. These are the safest default.
- Community libraries. OpenAI's page links to projects for PHP, Rust, Kotlin, Swift, Dart/Flutter, Elixir, Scala, Clojure, Delphi, Unity and Unreal Engine, with the warning that OpenAI does not verify their correctness or security. Popular examples include
openai-php/clientfor PHP,async-openaifor Rust andopenai-kotlinfor Kotlin. - Raw HTTP. Every language can do this: send
Authorization: Bearer $OPENAI_API_KEYand a JSON body tohttps://api.openai.com/v1/.... OpenAI publishes the OpenAPI specification, so you can also generate your own client.
How to pick:
- Your language is in the official list: use the official SDK.
- PHP, Rust, Kotlin, Swift and similar: a well-maintained community library saves time, but pin versions and read the changelog, because new endpoints can arrive weeks after OpenAI ships them.
- Small scripts, embedded systems or unusual languages: raw HTTP is often simpler than adding a dependency.
The same request in each official SDK
All official SDKs read OPENAI_API_KEY from the environment by default. The examples below call the Responses API with the model used in OpenAI's own quickstart at the time of writing; swap in any model your account has access to.
Python:
from openai import OpenAI
client = OpenAI() # reads OPENAI_API_KEY
response = client.responses.create(
model="gpt-6.2-astra",
input="Say this is a test.",
)
print(response.output_text)TypeScript or JavaScript (save as example.mjs for plain JavaScript):
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-6.2-astra",
input: "Say this is a test.",
});
console.log(response.output_text);Go:
client := openai.NewClient() // reads OPENAI_API_KEY
resp, err := client.Responses.New(context.TODO(), responses.ResponseNewParams{
Model: "gpt-6.2-astra",
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Say this is a test.")},
})
if err != nil {
panic(err)
}
fmt.Println(resp.OutputText())Java:
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ResponseCreateParams params = ResponseCreateParams.builder()
.input("Say this is a test.")
.model("gpt-6.2-astra")
.build();
Response response = client.responses().create(params);C#:
using OpenAI.Responses;
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
ResponseResult response = await client.CreateResponseAsync("gpt-6.2-astra", "Say this is a test.");
Console.WriteLine(response.GetOutputText());Ruby:
require "openai"
client = OpenAI::Client.new
response = client.responses.create(model: "gpt-6.2-astra", input: "Say this is a test.")
puts response.output_textAny other language, with curl as the reference request:
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6.2-astra", "input": "Say this is a test."}'If your language can reproduce that request, it can use the OpenAI API. For more copy-paste requests, see OpenAI API examples.
Pointing an SDK at a different base URL
Because the official SDKs speak a documented wire format, many other providers and gateways expose the same routes. That is what an OpenAI-compatible API means: you keep the SDK and change the base URL and key.
|
SDK |
How to change the base URL |
|---|---|
|
Python |
|
|
TypeScript / JavaScript |
|
|
Go |
|
|
Java |
|
|
C# / .NET |
|
|
Ruby |
|
Two things to check after switching. First, compatible providers usually implement Chat Completions (/v1/chat/completions) before the newer Responses API, so the Responses examples above may return 404 against a third-party endpoint while the Chat Completions equivalent works. Second, the base URL normally needs the /v1 suffix. Routing all your services through one OpenAI API proxy or gateway keeps this configuration in one place.
Picking a language for an OpenAI project
- Prototypes, data work, notebooks: Python. Most examples, cookbooks and third-party tutorials start here.
- Web apps, serverless, edge functions: TypeScript. The same package runs on Node.js, Deno and Bun.
- Enterprise backends: Java or C#, both with official, typed clients.
- High-concurrency services and CLIs: Go.
- Rails apps: Ruby, now with an official gem rather than only community options.
- Mobile: avoid calling the API directly from a shipped app, because the key would be exposed. Put a small backend or gateway in between, then use any HTTP client on the device.
FAQ
Does OpenAI have an official PHP SDK?
No. OpenAI's SDK page lists PHP only under community libraries (for example openai-php/client and orhanerday/open-ai). They work well for many teams, but OpenAI does not maintain or verify them.
Is there an official OpenAI SDK for Rust, Swift or Kotlin?
Not as of December 2026. These languages are covered by community libraries such as async-openai (Rust), MacPaw's OpenAI package (Swift) and openai-kotlin. Java's official SDK also works from Kotlin on the JVM.
Can I call the OpenAI API without an SDK?
Yes. Every endpoint is plain HTTPS with JSON (plus multipart for file uploads). Send the Authorization: Bearer header and the documented body. SDKs mainly add retries, typed models, streaming helpers and pagination.
Do the official SDKs work with OpenAI-compatible providers?
Usually, for the endpoints the provider implements. Set the base URL and the provider's key, and use the model names the provider lists. Features the provider has not implemented will return errors or be silently ignored, so test the exact calls you depend on.
Which language gets new API features first?
The official SDKs are generated from OpenAI's API specification and are normally updated when new endpoints ship. Community libraries depend on volunteer maintainers and can lag, so if you need a feature on launch day, prefer an official SDK or raw HTTP.