> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/en/developer/agents-api/assistant-to-agent-migration).

## Base URL

```
https://api.langdock.com/agent/v1/models
```

<Warning>
  **Dedicated deployments**

  Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.
</Warning>

## Example Request

```javascript theme={null}
const axios = require("axios");

async function getAvailableModels() {
  try {
    const response = await axios.get("https://api.langdock.com/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

<ResponseField name="object" type="string">
  Always 'list', indicating the top-level JSON object type.
</ResponseField>

<ResponseField name="data" type="array<Model>">
  Array containing available model objects.
</ResponseField>

<Accordion title="Model object fields">
  <ResponseField name="id" type="string">
    Value to send as `model` on create, update, and completions. When the deployment name maps to one accessible row, `id` is that name (for example `gpt-5`). When several rows share the name, `id` is that row's model UUID.
  </ResponseField>

  <ResponseField name="name" type="string">
    Deployment name for the row. Present on every row.
  </ResponseField>

  <ResponseField name="object" type="string">
    Always 'model', indicating the object type.
  </ResponseField>

  <ResponseField name="created" type="integer">
    Unix timestamp (ms) when the model was created.
  </ResponseField>

  <ResponseField name="region" type="string">
    Region where the model is available (e.g., "eu", "us", "global").
  </ResponseField>

  <ResponseField name="supportsExtendedThinking" type="boolean">
    Whether this model supports extended thinking mode.
  </ResponseField>
</Accordion>

```json Example response theme={null}
{
  "object": "list",
  "data": [
    {
      "id": "gpt-5",
      "name": "gpt-5",
      "object": "model",
      "created": 1686935735000,
      "region": "eu",
      "supportsExtendedThinking": false
    }
    // …other models
  ]
}
```

## Error Handling

```javascript theme={null}
try {
  const response = await axios.get("https://api.langdock.com/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;
    }
  }
}
```

Send `id` in the `model` field when you create a temporary agent. Completions rejects a deployment name that maps to more than one accessible row. Unique names and existing Anthropic aliases still work.

<CodeGroup>
  ```javascript agent.js theme={null}
  const response = await axios.post("https://api.langdock.com/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 agent.sh theme={null}
  curl https://api.langdock.com/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!" }] }
      ]
    }'
  ```
</CodeGroup>

<Info>
  Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


## OpenAPI

````yaml GET /agent/v1/models
openapi: 3.0.0
info:
  title: Langdock API
  version: 3.0.0
servers:
  - url: https://api.langdock.com
    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
                          description: >-
                            Value to send as model. The deployment name when it
                            maps to one accessible row, otherwise the model
                            UUID.
                        name:
                          type: string
                          description: Deployment name for the row.
                        object:
                          type: string
                        created:
                          type: integer
                        region:
                          type: string
                          description: Region where the model is available.
                        supportsExtendedThinking:
                          type: boolean
                          description: Whether this model supports extended thinking mode.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.