Open documentation ↗Overview
Use AI models such as ChatGPT or DALL-E to experience the capabilities of AI
OpenAI is a machine learning API from openai.com. Requests are authenticated with an API key. It is served over HTTPS and allows browser requests (CORS). Its OpenAPI description documents 28 endpoints.
At a glance
- Authentication
- API key
- HTTPS
- Yes
- CORS
- Yes
- Category
- Machine Learning
- Base URL
https://api.openai.com/v1- Version
- 1.2.0
- Endpoints
- 28
- OpenAPI
- Specification ↗
- Spec updated
- 2023-03-03
Make a first request
Replace the placeholders; the documentation says exactly where credentials go.
curl -X GET "https://api.openai.com/v1/files" \
-H "Accept: application/json" \
-H "X-API-Key: YOUR_API_KEY"const response = await fetch("https://api.openai.com/v1/files", {
method: "GET",
headers: {
"Accept": "application/json",
"X-API-Key": "YOUR_API_KEY",
},
});
const data = await response.json();
console.log(data);import requests
response = requests.request(
"GET",
"https://api.openai.com/v1/files",
headers={
"Accept": "application/json",
"X-API-Key": "YOUR_API_KEY",
},
timeout=30,
)
print(response.json())Endpoints
| Method | Path | What it does |
|---|---|---|
| POST | /answersdeprecated | Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents o |
| POST | /audio/transcriptions | Transcribes audio into the input language. |
| POST | /audio/translations | Translates audio into into English. |
| POST | /chat/completions | Creates a completion for the chat message |
| POST | /classificationsdeprecated | Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the o |
| POST | /completions | Creates a completion for the provided prompt and parameters |
| POST | /edits | Creates a new edit for the provided input, instruction, and parameters. |
| POST | /embeddings | Creates an embedding vector representing the input text. |
| GET | /enginesdeprecated | Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability. |
| GET | /engines/{engine_id}deprecated | Retrieves a model instance, providing basic information about it such as the owner and availability. |
| POST | /engines/{engine_id}/searchdeprecated | The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 o |
| GET | /files | Returns a list of files that belong to the user's organization. |
| POST | /files | Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be u |
| GET | /files/{file_id} | Returns information about a specific file. |
| DELETE | /files/{file_id} | Delete a file. |
| GET | /files/{file_id}/content | Returns the contents of the specified file |
| GET | /fine-tunes | List your organization's fine-tuning jobs |
| POST | /fine-tunes | Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fi |
| GET | /fine-tunes/{fine_tune_id} | Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning) |
| POST | /fine-tunes/{fine_tune_id}/cancel | Immediately cancel a fine-tune job. |
| GET | /fine-tunes/{fine_tune_id}/events | Get fine-grained status updates for a fine-tune job. |
| POST | /images/edits | Creates an edited or extended image given an original image and a prompt. |
| POST | /images/generations | Creates an image given a prompt. |
| POST | /images/variations | Creates a variation of a given image. |
| GET | /models | Lists the currently available models, and provides basic information about each one such as the owner and availability. |
| GET | /models/{model} | Retrieves a model instance, providing basic information about the model such as the owner and permissioning. |
| DELETE | /models/{model} | Delete a fine-tuned model. You must have the Owner role in your organization. |
| POST | /moderations | Classifies if text violates OpenAI's Content Policy |
Questions
Does the OpenAI API need an API key?
Yes. The OpenAI API uses API key authentication; the documentation explains how to get credentials.
Can I call the OpenAI API from the browser?
Yes. The OpenAI API sends CORS headers, so a web page can call it directly with fetch().
Does the OpenAI API support HTTPS?
Yes, the OpenAI API is served over HTTPS.
How many endpoints does the OpenAI API have?
Its OpenAPI description lists 28 endpoints in version 1.2.0. All of them are shown on this page.
What are alternatives to the OpenAI API?
Other Machine Learning APIs include Dialogflow, Hugging Face, WolframAlpha, OpenRouter, Laya Decision Gateway.
Similar machine learning APIs
Compare alternatives →Dialogflow
Machine LearningNatural Language Processing
Hugging Face
Machine LearningAI model hub with inference API for NLP, computer vision, and audio
WolframAlpha
Machine LearningProvides specific answers to questions using data and algorithms
OpenRouter
Machine LearningUnified API for 300+ LLMs from OpenAI, Anthropic, Meta, Mistral and more, with a free tier
Laya Decision Gateway
Machine LearningSub-35ms AI gateway for prompt injection defense, support ticket triage & content moderation
ElevenLabs API Documentation
Machine LearningThis is the documentation for the ElevenLabs API. You can use this API to use our service programmatically, this is done by using your xi-api-key. <br/> You can view your xi-api-key using the 'Profile' tab on https://beta.elevenlabs.io. Our API is experimental so all endpoints are subject to change.
Listed from public-apis database (MIT), APIs.guru (CC0).