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

# Chat Completions (OpenAI-compatible)

> OpenAI-compatible chat completions endpoint. Works with the standard OpenAI SDK — just change the base URL and API key.

Supports text, vision (image URLs and base64), and audio input in the standard OpenAI multimodal message format. Supports both streaming (Server-Sent Events) and non-streaming responses.

## OpenAI SDK Compatibility

This endpoint is fully compatible with the OpenAI SDK. Just change the `baseURL` and `apiKey`:

<CodeGroup>
  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: 'YOUR_EASY_PEASY_API_KEY',
    baseURL: 'https://easy-peasy.ai/api',
  });

  // Non-streaming
  const response = await client.chat.completions.create({
    model: 'gemini-3-flash',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Hello!' },
    ],
  });
  console.log(response.choices[0].message.content);

  // Streaming
  const stream = await client.chat.completions.create({
    model: 'gemini-3-flash',
    messages: [{ role: 'user', content: 'Tell me a story.' }],
    stream: true,
  });
  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
  }
  ```

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

  client = OpenAI(
      api_key="YOUR_EASY_PEASY_API_KEY",
      base_url="https://easy-peasy.ai/api",
  )

  response = client.chat.completions.create(
      model="gemini-3-flash",
      messages=[
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "Hello!"},
      ],
  )
  print(response.choices[0].message.content)
  ```

  ```bash cURL theme={null}
  curl -X POST https://easy-peasy.ai/api/chat/completions \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "messages": [
        {"role": "user", "content": "Hello!"}
      ],
      "model": "gemini-3-flash"
    }'
  ```
</CodeGroup>

## Authentication

This endpoint supports two authentication methods:

* **x-api-key header**: `x-api-key: YOUR_API_KEY`
* **Authorization header**: `Authorization: Bearer YOUR_API_KEY` (OpenAI SDK default)

## Supported Models

| Provider      | Model ID            | Description                                   |
| ------------- | ------------------- | --------------------------------------------- |
| **Google**    | `gemini-3-flash`    | Gemini 3 Flash — fast and efficient (default) |
| **Google**    | `gemini-3-pro`      | Gemini 3 Pro — advanced reasoning             |
| **Google**    | `gemini-3.1-pro`    | Gemini 3.1 Pro — latest Gemini                |
| **Anthropic** | `claude-opus-4-6`   | Claude Opus 4.6 — most capable                |
| **Anthropic** | `claude-sonnet-4-6` | Claude Sonnet 4.6 — balanced                  |
| **Anthropic** | `claude-haiku-4-5`  | Claude Haiku 4.5 — fast                       |
| **OpenAI**    | `gpt-5`             | GPT-5 — latest flagship                       |
| **OpenAI**    | `gpt-5-mini`        | GPT-5 Mini — smaller, fast                    |
| **OpenAI**    | `gpt-5.4-instant`   | GPT-5.4 Instant — fast                        |
| **OpenAI**    | `gpt-5.4-thinking`  | GPT-5.4 Thinking — reasoning                  |
| **OpenAI**    | `gpt-5.4-pro`       | GPT-5.4 Pro — most capable                    |
| **DeepSeek**  | `deepseek-v3`       | DeepSeek V3                                   |
| **Kimi**      | `kimi-k2.5`         | Kimi K2.5                                     |
| **GLM**       | `glm-5`             | GLM-5                                         |
| **MiniMax**   | `minimax-m2p5`      | MiniMax M2.5                                  |
| **xAI**       | `grok-4`            | Grok 4                                        |

## Multimodal Messages

You can send images and audio alongside text using the OpenAI multimodal message format.

### Vision (Image Input)

Send images as URLs or base64 data URIs:

<CodeGroup>
  ```javascript Node.js theme={null}
  const response = await client.chat.completions.create({
    model: 'gemini-3-flash',
    messages: [
      {
        role: 'user',
        content: [
          { type: 'text', text: 'What do you see in this image?' },
          {
            type: 'image_url',
            image_url: { url: 'https://example.com/photo.jpg' },
          },
        ],
      },
    ],
  });
  ```

  ```python Python theme={null}
  response = client.chat.completions.create(
      model="gemini-3-flash",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "What do you see in this image?"},
                  {
                      "type": "image_url",
                      "image_url": {"url": "https://example.com/photo.jpg"},
                  },
              ],
          }
      ],
  )
  ```

  ```bash cURL theme={null}
  curl -X POST https://easy-peasy.ai/api/chat/completions \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "messages": [{
        "role": "user",
        "content": [
          {"type": "text", "text": "What do you see?"},
          {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
        ]
      }]
    }'
  ```
</CodeGroup>

Base64 images are also supported:

```json theme={null}
{
  "type": "image_url",
  "image_url": {
    "url": "data:image/png;base64,iVBORw0KGgo..."
  }
}
```

### Audio Input

Send audio as base64-encoded data (mp3, wav, webm, mp4):

```json theme={null}
{
  "role": "user",
  "content": [
    { "type": "text", "text": "Transcribe this audio." },
    {
      "type": "input_audio",
      "input_audio": {
        "data": "base64-encoded-audio-data...",
        "format": "mp3"
      }
    }
  ]
}
```

## Streaming

When `stream: true`, the response uses Server-Sent Events in OpenAI chunk format:

```
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":...,"model":"gemini-3-flash","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":...,"model":"gemini-3-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]
```


## OpenAPI

````yaml POST /api/chat/completions
openapi: 3.0.1
info:
  title: Easy-Peasy.AI API
  description: >-
    OpenAPI Specifications for the Easy-Peasy.AI API.


    All API requests must be authenticated with an API key. Include the
    `x-api-key` API key in the request header with all requests. You can get the
    API key [here](https://easy-peasy.ai/settings/api).
  version: 1.0.4
servers:
  - url: https://easy-peasy.ai
security:
  - apiKeyAuth: []
paths:
  /api/chat/completions:
    post:
      summary: Chat Completions (OpenAI-compatible)
      description: >-
        OpenAI-compatible chat completions endpoint. Works with the standard
        OpenAI SDK — just change the base URL and API key.


        Supports text, vision (image URLs and base64), and audio input in the
        standard OpenAI multimodal message format. Supports both streaming
        (Server-Sent Events) and non-streaming responses.
      operationId: chatCompletions
      parameters:
        - name: x-api-key
          in: header
          required: false
          schema:
            type: string
          description: 'Your API key. Alternatively, use the `Authorization: Bearer` header.'
          example: 27feb2bb-aeb4-4a83-9fb6-8f3f2a15885e
        - name: Authorization
          in: header
          required: false
          schema:
            type: string
          description: >-
            Bearer token authentication (alternative to x-api-key). Format:
            `Bearer YOUR_API_KEY`
          example: Bearer 27feb2bb-aeb4-4a83-9fb6-8f3f2a15885e
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionsRequest'
            example:
              messages:
                - role: system
                  content: You are a helpful assistant.
                - role: user
                  content: Explain quantum computing in simple terms.
              model: gemini-3-flash
              temperature: 0.7
              max_tokens: 1000
      responses:
        '200':
          description: Chat completion response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionsResponse'
              example:
                id: chatcmpl-1741234567890
                object: chat.completion
                created: 1741234567
                model: gemini-3-flash
                choices:
                  - index: 0
                    message:
                      role: assistant
                      content: Quantum computing is...
                    finish_reason: stop
                usage:
                  prompt_tokens: 25
                  completion_tokens: 150
                  total_tokens: 175
        '400':
          description: Bad request — messages is missing or empty
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
              example:
                error:
                  message: messages is required and must be a non-empty array
                  type: server_error
        '401':
          description: Invalid or missing API key, or account blocked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
              example:
                error:
                  message: Invalid API key
                  type: server_error
        '429':
          description: Token limit reached for subscription
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
              example:
                error:
                  message: Token limit reached for your subscription plan
                  type: server_error
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
              example:
                error:
                  message: Internal server error
                  type: server_error
components:
  schemas:
    ChatCompletionsRequest:
      type: object
      required:
        - messages
      properties:
        messages:
          type: array
          description: Array of message objects for the conversation
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                enum:
                  - system
                  - user
                  - assistant
                description: The role of the message author
              content:
                oneOf:
                  - type: string
                    description: Text content of the message
                  - type: array
                    description: Multimodal content array (text, images, audio)
                    items:
                      oneOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - text
                            text:
                              type: string
                          required:
                            - type
                            - text
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - image_url
                            image_url:
                              type: object
                              properties:
                                url:
                                  type: string
                                  description: >-
                                    Image URL or base64 data URI
                                    (data:image/png;base64,...)
                              required:
                                - url
                          required:
                            - type
                            - image_url
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - input_audio
                            input_audio:
                              type: object
                              properties:
                                data:
                                  type: string
                                  description: Base64-encoded audio data
                                format:
                                  type: string
                                  enum:
                                    - mp3
                                    - wav
                                    - webm
                                    - mp4
                                  description: Audio format
                              required:
                                - data
                                - format
                          required:
                            - type
                            - input_audio
                description: >-
                  Message content — a string for text, or an array for
                  multimodal (text, images, audio)
        model:
          type: string
          default: gemini-3-flash
          description: >-
            Model to use for the completion. See the models table below for all
            supported models.
          enum:
            - gemini-3-flash
            - gemini-3-pro
            - gemini-3.1-pro
            - claude-opus-4-6
            - claude-sonnet-4-6
            - claude-haiku-4-5
            - gpt-5
            - gpt-5-mini
            - gpt-5.4-instant
            - gpt-5.4-thinking
            - gpt-5.4-pro
            - deepseek-v3
            - kimi-k2.5
            - glm-5
            - minimax-m2p5
            - grok-4
        stream:
          type: boolean
          default: false
          description: Enable Server-Sent Events streaming
        temperature:
          type: number
          description: Sampling temperature (0-2)
        max_tokens:
          type: integer
          description: Maximum tokens to generate
        top_p:
          type: number
          description: Nucleus sampling parameter
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: Stop sequences
    ChatCompletionsResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the completion
        object:
          type: string
          enum:
            - chat.completion
          description: Object type
        created:
          type: integer
          description: Unix timestamp of creation
        model:
          type: string
          description: Model used for the completion
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                  content:
                    type: string
              finish_reason:
                type: string
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
    OpenAIError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Error description
            type:
              type: string
              description: Error type
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Get yours at
        https://easy-peasy.ai/settings/api

````