Models
List and retrieve information about available AI models.
List All Models
Endpoint
GET /api/v1/models
Request
curl http://localhost/api/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"object": "list",
"data": [
{
"id": "gpt-4",
"object": "model",
"created": 1234567890,
"owned_by": "system"
},
{
"id": "gpt-3.5-turbo",
"object": "model",
"created": 1234567890,
"owned_by": "system"
},
{
"id": "text-embedding-ada-002",
"object": "model",
"created": 1234567890,
"owned_by": "system"
}
]
}
Python Example
import requests
response = requests.get(
"http://localhost/api/v1/models",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
models = response.json()["data"]
for model in models:
print(f"Model ID: {model['id']}")
print(f"Owned by: {model['owned_by']}")
print("-" * 40)
JavaScript Example
const response = await fetch('http://localhost/api/v1/models', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
data.data.forEach(model => {
console.log(`Model ID: ${model.id}`);
console.log(`Owned by: ${model.owned_by}`);
});
Get Model Details
Endpoint
GET /api/v1/models/{model_id}
Request
curl http://localhost/api/v1/models/gpt-4 \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"id": "gpt-4",
"object": "model",
"created": 1234567890,
"owned_by": "system"
}
Python Example
import requests
model_id = "gpt-4"
response = requests.get(
f"http://localhost/api/v1/models/{model_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
model = response.json()
print(f"Model: {model['id']}")
print(f"Created: {model['created']}")
print(f"Owner: {model['owned_by']}")
Available Models
Chat Models
| Model ID | Description | Max Tokens |
|---|---|---|
gpt-4 | Most capable model | 8192 |
gpt-4-32k | GPT-4 with 32k context | 32768 |
gpt-3.5-turbo | Fast, cost-effective | 4096 |
gpt-3.5-turbo-16k | GPT-3.5 with 16k context | 16384 |
Embedding Models
| Model ID | Description | Dimensions |
|---|---|---|
text-embedding-ada-002 | General purpose text embeddings | 1536 |
Model Selection Guide
Choose GPT-4 When:
- Complex reasoning tasks
- Code generation and debugging
- Creative writing requiring nuanced understanding
- Budget allows for higher costs
Choose GPT-3.5-Turbo When:
- Fast responses needed
- Cost efficiency is important
- Simple queries and responses
- High volume of requests
Choose 32k Context When:
- Long documents need processing
- Multi-part conversations
- Complex prompts with lots of context
- Maintaining conversation history
Error Handling
Model Not Found
{
"error": {
"message": "Model 'gpt-5' not found",
"type": "invalid_request_error",
"code": "model_not_found"
}
}
Solution: Check available models with GET /api/v1/models
Authentication Error
{
"error": {
"message": "Invalid authentication credentials",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
Solution: Verify your API key is correct and active
Best Practices
- Check Available Models - Query
/api/v1/modelsbefore using a specific model - Handle Errors Gracefully - Model availability may change
- Use Appropriate Models - Balance capability with cost
- Cache Model List - Models don't change frequently, cache to reduce API calls
Next Steps
- Chat Completions - Use models to generate text
- Embeddings - Use embedding models
- Integration Examples - See how to use with clients