#SMNX_Token $BTC

BTC
BTCUSDT
75,914.8
-3.76%

"

Primary navigation

API

API Reference

Codex

ChatGPT

Resources

Search docs

Suggested

response_format

reasoning_effort

streaming

tools

Get started

Overview

Quickstart

Models

Pricing

Latest: GPT-5.5

Prompt guidance

Core concepts

Text generation

Code generation

Images and vision

Audio and speech

Structured output

Function calling

Responses API

Using tools

Agents SDK

Overview

Quickstart

Agent definitions

Models and providers

Running agents

Sandbox agents

Orchestration

Guardrails

Results and state

Integrations and observability

Evaluate agent workflows

Voice agents

Tools

Web search

MCP and Connectors

Skills

Shell

Computer use

Tool search

Run and scale

Conversation state

Background mode

Streaming

WebSocket mode

Webhooks

File inputs

Evaluation

Getting started

Working with evals

Prompt optimizer

External models

Best practices

Realtime and audio

Overview

Voice agents

Live translation

Speech generation

Realtime prompting guide

Model optimization

Optimization cycle

Graders

Specialized models

Image generation

Video generation

Deep research

Embeddings

Moderation

Going live

Production best practices

Deployment checklist

Accuracy optimization

Legacy APIs

Resources

Terms and policies

Changelog

Your data

Permissions

Rate limits

Admin APIs

Deprecations

MCP for deep research

Developer mode

Developer quickstart

Take your first steps with the OpenAI API.

Copy Page

The OpenAI API provides a simple interface to state-of-the-art AI models for text generation, natural language processing, computer vision, and more. Get started by creating an API Key and running your first API call. Discover how to generate text, analyze images, build agents, and more.

Build with the OpenAI API in Codex

The OpenAI Developers plugin enables Codex to connect to the OpenAI Platform, follow OpenAI API setup guidance, and create project API keys when your app needs one.

Create and export an API key

Before you begin, create an API key in the dashboard, which you’ll use to securely access the API. Store the key in a safe location, like a .zshrc file or another text file on your computer. Once you’ve generated an API key, export it as an environment variable in your terminal.

macOS / Linux

Windows

Export an environment variable on macOS or Linux systems

export OPENAI_API_KEY="your_api_key_here"

OpenAI SDKs are configured to automatically read your API key from the system environment.

Install the OpenAI SDK and Run an API Call

JavaScript

Python

.NET

Java

Go

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-5.5",

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.

Responses starter app

Start building with the Responses API.

Text generation and prompting

Learn more about prompting, message roles, and building conversational apps.

Add credits to keep building

Congrats on running a free test API request! Start building real applications with higher limits and use our models to generate text, audio, images, videos and more.

Access dashboard features designed to help you ship faster:

Chat Playground

Build & test conversational prompts and embed them in your app.

Agent Builder

Build, deploy, and optimize agent workflows.

Analyze images and files

Send image URLs, uploaded files, or PDF documents directly to the model to extract text, classify content, or detect visual elements.

Image URL

File URL

Upload file

Analyze the content of an image

import OpenAI from "openai";

const client = new OpenAI();

const response = await client.responses.create({

model: "gpt-5.5",

input: [

{

role: "user",

content: [

{

type: "input_text",

text: "What is in this image?",

},

{

type: "input_image",

image_url: "https://public.bnbstatic.com/static/content/square/images/b601711066c348f58b95dabca72d6e71.png",

},

],

},

],

});

console.log(response.output_text);

Image inputs guide

Learn to use image inputs to the model and extract meaning from images.

File inputs guide

Learn to use file inputs to the model and extract meaning from documents.

Extend the model with tools

Give the model access to external data and functions by attaching tools. Use built-in tools like web search or file search, or define your own for calling APIs, running code, or integrating with third-party systems.

Web search

File search

Function calling

Remote MCP

Use web search in a response

import OpenAI from "openai";

const client = new OpenAI();

const response = await client.responses.create({

model: "gpt-5.5",

tools: [

{ type: "web_search" },

],

input: "What was a positive news story from today?",

});

console.log(response.output_text);

Use built-in tools

Learn about powerful built-in tools like web search and file search.

Function calling guide

Learn to enable the model to call your own custom code.

Stream responses and build realtime apps

Use server‑sent streaming events to show results as they’re generated, or the Realtime API for interactive voice and multimodal apps.

Stream server-sent events from the API

import { OpenAI } from "openai";

const client = new OpenAI();

const stream = await client.responses.create({

model: "gpt-5.5",

input: [

{

role: "user",

content: "Say 'double bubble bath' ten times fast.",

},

],

stream: true,

});

for await (const event of stream) {

console.log(event);

}

Use streaming events

Use server-sent events to stream model responses to users fast.

Get started with the Realtime API

Use WebRTC or WebSockets for super fast speech-to-speech AI apps.

Build agents

Use the OpenAI platform to build agents capable of taking action—like controlling computers—on behalf of your users. Use the Agents SDK to create orchestration logic on the backend.

Build a language triage agent

import { Agent, run } from '@openai/agents';

const spanishAgent = new Agent({

name: 'Spanish agent',

instructions: 'You only speak Spanish.',

});

const englishAgent = new Agent({

name: 'English agent',

instructions: 'You only speak English',

});

const triageAgent = new Agent({

name: 'Triage agent',

instructions:

'Handoff to the appropriate agent based on the language of the request.',

handoffs: [spanishAgent, englishAgent],

});

const result = await run(triageAgent, 'Hola, ¿cómo estás?');

console.log(result.finalOutput);

Build agents that can take action

Learn how to use the OpenAI platform to build powerful, capable AI agents."

https://developers.openai.com/api/docs/quickstart#:~:text=Primary%20navigation,capable%20AI%20agents.sync/https://developers.openai.com/api/docs/quickstart#:~:text=Primary%20navigation,capable%20AI%20agents.https://public.bnbstatic.com/static/content/square/images/b601711066c348f58b95dabca72d6e71.png-/manus.space/code/command/deploy$BTC