Retrieves information about a specific model. This endpoint does not require authentication.
Path Parameters
The model ID to retrieve (e.g., gpt-4, claude-3-5-sonnet).
Response
Unix timestamp of when the model was added.
The organization that owns the model.
Examples
Get Model Details
from openai import OpenAI
client = OpenAI(
api_key="sk-voidai-your_key_here",
base_url="https://api.voidai.app/v1"
)
model = client.models.retrieve("gpt-4")
print(f"Model: {model.id}")
print(f"Provider: {model.owned_by}")
print(f"Created: {model.created}")
Check Model Exists
from openai import OpenAI, NotFoundError
client = OpenAI(
api_key="sk-voidai-your_key_here",
base_url="https://api.voidai.app/v1"
)
def model_exists(model_id):
try:
client.models.retrieve(model_id)
return True
except NotFoundError:
return False
# Usage
if model_exists("gpt-4"):
print("GPT-4 is available!")
else:
print("GPT-4 is not available")
Response Example
{
"id": "gpt-4",
"object": "model",
"created": 1687882411,
"owned_by": "openai"
}
Error Response
If the model doesn’t exist:
{
"error": {
"message": "Model 'invalid-model' not found",
"type": "api_error",
"code": "MODEL_NOT_FOUND"
}
}