Use this file to discover all available pages before exploring further.
This page covers setting up your local development environment to use the OpenAI API. You can use one of our officially supported SDKs, a community library, or your own preferred HTTP client.
To use the OpenAI API in server-side JavaScript environments like Node.js, Deno, or Bun, you can use the official OpenAI SDK for TypeScript and JavaScript. Get started by installing the SDK using npm or your preferred package manager:
Install the OpenAI SDK with npm
npm install openai
With the OpenAI SDK installed, create a file called example.mjs and copy the example code into it:
Test a basic API request
import OpenAI from "openai";const client = new OpenAI();const response = await client.responses.create({ model: "gpt-4.1", input: "Write a one-sentence bedtime story about a unicorn."});console.log(response.output_text);
Execute the code with node example.mjs (or the equivalent command for Deno or Bun). In a few moments, you should see the output of your API request.
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
To use the OpenAI API in Python, you can use the official OpenAI SDK for Python. Get started by installing the SDK using pip:
Install the OpenAI SDK with pip
pip install openai
With the OpenAI SDK installed, create a file called example.py and copy the example code into it:
Test a basic API request
from openai import OpenAIclient = OpenAI()response = client.responses.create( model="gpt-4.1", input="Write a one-sentence bedtime story about a unicorn.")print(response.output_text)
Execute the code with python example.py. In a few moments, you should see the output of your API request.
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
In collaboration with Microsoft, OpenAI provides an officially supported API client for C#. You can install it with the .NET CLI from NuGet.
using OpenAI.Chat;ChatClient client = new( model: "gpt-4.1", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));ChatCompletion completion = client.CompleteChat("Say 'this is a test.'");Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
To learn more about using the OpenAI API in .NET, check out the GitHub repo linked below!
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
OpenAI provides an API helper for the Java programming language, currently in beta. You can include the Maven depency using the following configuration:
Microsoft’s Azure team maintains libraries that are compatible with both the OpenAI API and Azure OpenAI services. Read the library documentation below to learn how you can use them with the OpenAI API.
The libraries below are built and maintained by the broader developer community. You can also watch our OpenAPI specification repository on GitHub to get timely updates on when we make changes to our API.Please note that OpenAI does not verify the correctness or security of these projects. Use them at your own risk!