Skip to main content

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 IDDescriptionMax Tokens
gpt-4Most capable model8192
gpt-4-32kGPT-4 with 32k context32768
gpt-3.5-turboFast, cost-effective4096
gpt-3.5-turbo-16kGPT-3.5 with 16k context16384

Embedding Models

Model IDDescriptionDimensions
text-embedding-ada-002General purpose text embeddings1536

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

  1. Check Available Models - Query /api/v1/models before using a specific model
  2. Handle Errors Gracefully - Model availability may change
  3. Use Appropriate Models - Balance capability with cost
  4. Cache Model List - Models don't change frequently, cache to reduce API calls

Next Steps