OpenAI
POST /v1/responses
Checked 2026-07-19. Endpoint and headers follow the linked provider reference.
REST examples
Python standard library
import json, os, urllib.request
url = "https://api.openai.com/v1/responses"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer " + os.environ["OPENAI_API_KEY"]
}
payload = {
"model": "<MODEL_ID>",
"input": "Hello"
}
data = json.dumps(payload).encode("utf-8")
request = urllib.request.Request(url, data=data, headers=headers, method="POST")
with urllib.request.urlopen(request) as response:
print(response.read().decode("utf-8"))JavaScript fetch
const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) throw new Error("Missing OPENAI_API_KEY");
const response = await fetch("https://api.openai.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + apiKey
},
body: JSON.stringify({
"model": "<MODEL_ID>",
"input": "Hello"
})
});
console.log(await response.json());Java HttpClient
var apiKey = System.getenv("OPENAI_API_KEY");
if (apiKey == null || apiKey.isBlank()) throw new IllegalStateException("Missing OPENAI_API_KEY");
var client = java.net.http.HttpClient.newHttpClient();
var request = java.net.http.HttpRequest.newBuilder(java.net.URI.create("https://api.openai.com/v1/responses"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + apiKey)
.POST(java.net.http.HttpRequest.BodyPublishers.ofString("{\"model\":\"<MODEL_ID>\",\"input\":\"Hello\"}"))
.build();
var response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());Official SDKs
- Python: Official SDK ↗
- JavaScript: Official SDK ↗
- Java: Official SDK ↗
Limits and pricing
Limits vary by model, project or organization, usage tier, and request type; no single RPM or TPM value is presented here. Rate-limit documentation ↗
Pricing varies by model, feature, and processing mode. Directory model prices remain model-specific snapshots. Pricing documentation ↗
| Catalog model | Input / 1M | Output / 1M | Price scope |
|---|---|---|---|
| GPT-4.1 | $2.00 | $8.00 | Provider-listed snapshot; verify current rules |
| GPT-5.6 Sol | $5.00 | $30.00 | Provider-listed snapshot; verify current rules |
| GPT-5.6 Terra | $2.50 | $15.00 | Provider-listed snapshot; verify current rules |
| GPT-5.6 Luna | $1.00 | $6.00 | Provider-listed snapshot; verify current rules |