Skip to content
ajan.io

Docs menu

On this page

Models for Agent API

Retrieve all available models for use with the Agent API.

Retrieve the list of models and their ids, available for use with the Agent API. This endpoint is useful when you want to see which models you can use when creating a temporary agent.

Before You Start

  • Legacy Assistants API: This is the new Agents API with native Vercel AI SDK compatibility. If you're using the legacy Assistants API, see the migration guide.

Base URL

https://api.ajan.io/agent/v1/models

Example Request

javascript
const axios = require("axios");

async function getAvailableModels() {
  try {
    const response = await axios.get("https://api.ajan.io/agent/v1/models", {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
      },
    });

    console.log("Available models:", response.data.data);
  } catch (error) {
    console.error("Error fetching models:", error);
  }
}

Response Format

The API returns a list of available models in the following format:

Response Fields

Always 'list', indicating the top-level JSON object type.

"> Array containing available model objects.

Model ID to use when creating or updating agents (e.g., "gpt-5").

Always 'model', indicating the object type.

Unix timestamp (ms) when the model was created.

Region where the model is available (e.g., "eu", "us", "global").

Whether this model supports extended thinking mode.

json
{
  "object": "list",
  "data": [
    {
      "id": "gpt-5",
      "object": "model",
      "created": 1686935735000,
      "region": "eu",
      "supportsExtendedThinking": false
    }
    // …other models
  ]
}

Error Handling

javascript
try {
  const response = await axios.get("https://api.ajan.io/agent/v1/models", {
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
    },
  });
} catch (error) {
  if (error.response) {
    switch (error.response.status) {
      case 400:
        console.error("Invalid request parameters");
        break;
      case 401:
        console.error("Invalid API key");
        break;
      case 500:
        console.error("Internal server error");
        break;
    }
  }
}

You can use any of these model IDs when creating a temporary agent through the Agent API. Simply specify the model ID in the model field of your agent configuration:

javascript
  const response = await axios.post("https://api.ajan.io/agent/v1/chat/completions", {
    agent: {
      name: "Custom Agent",
      instructions: "You are a helpful agent",
      model: "gpt-5", // Specify the model ID here
    },
    messages: [
      { id: "msg_1", role: "user", parts: [{ type: "text", text: "Hello!" }] },
    ],
  });
bash
  curl https://api.ajan.io/agent/v1/chat/completions \
    -H "Authorization: Bearer $API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "agent": {
        "name": "Custom Agent",
        "instructions": "You are a helpful agent",
        "model": "gpt-5"
      },
      "messages": [
        { "id": "msg_1", "role": "user", "parts": [{ "type": "text", "text": "Hello!" }] }
      ]
    }'

OpenAPI

openapi: 3.0.0
info:
  title: ajan API
  version: 3.0.0
servers:
  - url: https://api.ajan.io
    description: Production
security:
  - bearerAuth: []
paths:
  /agent/v1/models:
    get:
      tags:
        - Agent
      summary: Lists the available models
      description: Returns a list of models that are available for use with the API.
      parameters: []
      responses:
        '200':
          description: List of available models
          content:
            application/json:
              schema:
                type: object
                required:
                  - object
                  - data
                properties:
                  object:
                    type: string
                    enum:
                      - list
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        object:
                          type: string
                        created:
                          type: integer
                        owned_by:
                          type: string
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"