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

# Execute OpenAI Compatible

> Execute a specific **chat** agent by ID using the OpenAI-compatible API.

### **Code Examples**

See the [OpenAI SDK](https://platform.openai.com/docs/libraries) documentation for more info. At the moment, our API only support the `temperature` and `messages` (roles `system`, `user` and `assistant`) model parameters. Additionally, the `tools` parameter is a `string` enum. To verify the model parameters of an specific agent, see the [Get Agent](https://docs.tess.im/en/get-agent.md) endpoint.

```http cURL theme={null}
curl --request POST \
  --url 'https://api.tess.im/agents/{id}/openai/chat/completions' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'x-workspace-id: YOUR_WORKSPACE_ID' \
  --header 'Content-Type: application/json' \
  --data '{
    "temperature": "1",
    "model": "tess-5",
    "messages": [{ "role": "user", "content": "hello there!" }],
    "tools": "no-tools",
    "stream": true
  }'
```

```json Node.js theme={null}
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.tess.im/agents/{id}/openai',
  apiKey: 'YOUR_API_KEY',
});

async function main() {
  const chatCompletion = await client.chat.completions.create({
    messages: [{ role: 'user', content: 'Say this is a test' }],
    model: 'gpt-4o',
  });
}

main();
```

```python Python theme={null}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tess.im/agents/{id}/openai",
    api_key="YOUR_API_KEY"
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-4o",
)
```

### **Headers**

**x-workspace-id** `integer` *required*

Workspace ID. **Required as of 2026-09-01.** Until then, if omitted, the user's selected workspace is used (deprecated). After the cutoff, a missing header returns **422**.

### **Path Parameters**

| **Parameter** | **Type** | **Required** | **Description** |
| :- | :- | :- | :- |
| `id` | integer | Yes | The agent ID. |

### **Request Body**

See the [OpenAI API documentation](https://platform.openai.com/docs/api-reference/chat/create) for the full parameter reference. At the moment, our API only supports the `temperature` and `messages` (roles `system`, `user` and `assistant`) model parameters. Additionally, the `tools` parameter is a `string` enum. To verify the model parameters of a specific agent, see the [Get Agent](https://docs.tess.im/en/get-agent.md) endpoint.

### **Response**

See the [OpenAI API documentation](https://platform.openai.com/docs/api-reference/chat/object) for the response format.


## OpenAPI

````yaml api-reference/agents-execution.openapi.json POST /agents/{id}/openai/chat/completions
openapi: 3.1.0
info:
  title: Tess API - Agent Execution
  version: 1.0.0
servers:
  - url: https://api.tess.im
security: []
paths:
  /agents/{id}/openai/chat/completions:
    post:
      summary: Execute OpenAI Compatible
      description: Execute a specific chat agent by ID using the OpenAI-compatible API.
      operationId: executeOpenAICompatible
      parameters:
        - $ref: '#/components/parameters/agentId'
        - $ref: '#/components/parameters/workspaceId'
      requestBody:
        description: >-
          Send a JSON object in OpenAI-compatible format. You can also include
          custom root-level fields when needed by your agent configuration.
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              description: >-
                Free-form JSON object in OpenAI-compatible format. Custom fields
                can also be sent at the root level.
            example:
              temperature: 1
              model: tess-6
              messages:
                - role: user
                  content: Create a short release note.
              tools: no-tools
              stream: false
            examples:
              defaultChatCompletion:
                summary: Default OpenAI-compatible payload
                value:
                  temperature: 1
                  model: tess-6
                  messages:
                    - role: user
                      content: Create a short release note.
                  tools: no-tools
                  stream: false
              customFieldsAtRoot:
                summary: OpenAI-compatible payload with custom fields
                value:
                  temperature: 1
                  messages:
                    - role: user
                      content: Suggest improvements for onboarding.
                  tenant: enterprise-a
                  persona: manager
      responses:
        '200':
          description: Chat completion response.
      security:
        - bearerAuth: []
components:
  parameters:
    agentId:
      name: id
      in: path
      required: true
      schema:
        type: integer
      description: The agent ID.
    workspaceId:
      name: x-workspace-id
      in: header
      required: true
      schema:
        type: integer
      description: >-
        Workspace ID. Required as of 2026-09-01. Until then, if omitted, the
        user's selected workspace is used (deprecated). After the cutoff, a
        missing header returns 422.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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