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

# Chat Completions

> Generate responses from AI models based on conversation history

# Chat Completions API

The Chat Completions API allows you to have dynamic conversations with AI models. This endpoint enables you to send a series of messages and receive AI-generated responses that maintain context throughout the conversation.

## Features

* Support for multiple advanced AI models
* Streaming responses for real-time applications
* Temperature and other control parameters
* Function calling capabilities

## Example Usage

### Models

Available models for chat completions:

* `wizardlm-2-7b`
* `claude-3-5-sonnet`
* `gpt-4o-mini`

### Example Request

```json theme={null}
{
  "stream": false,
  "model": "wizardlm-2-7b",
  "messages": [
    {
      "role": "user",
      "content": "What is artificial intelligence?"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 1500
}
```

### Example With Function Calling

```json theme={null}
{
  "stream": false,
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "user",
      "content": "What's the weather like in New York?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state"
            },
            "unit": {
              "type": "string",
              "enum": ["celsius", "fahrenheit"]
            }
          },
          "required": ["location"]
        }
      }
    }
  ]
}
```

### Example With Image Recognition

```json theme={null}
{
  "stream": false,
  "model": "claude-3-5-sonnet",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What's in this image?"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/image.jpg",
            "detail": "auto"
          }
        }
      ]
    }
  ]
}
```


## OpenAPI

````yaml POST /v1/chat/completions
openapi: 3.0.1
info:
  title: TaamCloud API
  description: >-
    A collection of AI services including chat, embeddings, reranking, and media
    generation
  version: 1.0.0
servers:
  - url: https://api.gately.ai
    description: Main API server
  - url: https://uploud.taam.cloud
    description: File Processing server
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat
      summary: Chat completions
      description: Generate chat completions based on provided conversation history
      operationId: chat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
            examples:
              Simple:
                value:
                  model: gpt-4
                  messages:
                    - role: system
                      content: You are a helpful assistant.
                    - role: user
                      content: Hello, how are you today?
                  temperature: 0.7
                  max_tokens: 150
      responses:
        '200':
          description: Successful response
components:
  schemas:
    ChatRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
        messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
        temperature:
          type: number
        max_tokens:
          type: integer
        stream:
          type: boolean
          default: false
          description: Whether to stream the response
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - system
        content:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Enter your API key prefixed with 'Bearer '

````