Loading…
Glossary term
Application programming interface: a way for software to request services, such as a model's output, from another system.
An API is a defined way for one program to ask another for something. Most AI models are offered through a web API: you send a request, such as a prompt, and get a response back, usually as JSON. Providers charge by usage, often per token.
A typical API request
import requests
response = requests.post(
"https://api.example.com/v1/chat",
headers={"Authorization": "Bearer YOUR_KEY"},
json={"model": "model-name", "messages": [{"role": "user", "content": "Hello"}]},
)
print(response.json())APIs let developers build products on top of models without running any AI hardware.