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

> Build conversational AI applications using Eden AI's OpenAI-compatible chat completions endpoint.

# Chat completions

export const TechArticleSchema = ({title, description, path, articleSection, about, proficiencyLevel = "Beginner", dependencies, keywords = [], datePublished, dateModified, image, inLanguage = "en"}) => {
  const baseUrl = "https://www.edenai.co/docs";
  const canonicalUrl = `${baseUrl}/${path}`.replace(/\/+$/, "");
  const ogParams = new URLSearchParams({
    division: articleSection || "",
    title: title || "",
    description: description || ""
  });
  const resolvedImage = image || `https://edenai.mintlify.app/_mintlify/api/og?${ogParams.toString()}`;
  const data = {
    "@context": "https://schema.org",
    "@type": "TechArticle",
    "@id": `${canonicalUrl}#techarticle`,
    mainEntityOfPage: {
      "@type": "WebPage",
      "@id": canonicalUrl
    },
    headline: title,
    name: title,
    description: description,
    url: canonicalUrl,
    inLanguage: inLanguage,
    isPartOf: {
      "@type": "WebSite",
      name: "Eden AI Documentation",
      url: baseUrl
    },
    author: [{
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/"
    }],
    publisher: {
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/",
      logo: {
        "@type": "ImageObject",
        url: "https://www.edenai.co/assets/logo.png"
      }
    }
  };
  if (articleSection) data.articleSection = articleSection;
  if (about) data.about = {
    "@type": "Thing",
    name: about
  };
  if (proficiencyLevel) data.proficiencyLevel = proficiencyLevel;
  if (dependencies) data.dependencies = dependencies;
  if (keywords && keywords.length) data.keywords = keywords;
  if (datePublished) data.datePublished = datePublished;
  if (dateModified) data.dateModified = dateModified;
  data.image = Array.isArray(resolvedImage) ? resolvedImage : [resolvedImage];
  const json = JSON.stringify(data);
  const schemaId = `techarticle-${canonicalUrl}`;
  React.useEffect(() => {
    if (typeof document === "undefined") return;
    document.querySelectorAll(`script[data-schema-id="${schemaId}"]`).forEach(n => n.remove());
    const script = document.createElement("script");
    script.type = "application/ld+json";
    script.dataset.schemaId = schemaId;
    script.textContent = json;
    document.head.appendChild(script);
    return () => script.remove();
  }, [json, schemaId]);
  return null;
};

<TechArticleSchema title={"Chat Completions"} description={"Build conversational AI applications using Eden AI's OpenAI-compatible chat completions endpoint."} path="v3/llms/chat-completions" articleSection="LLMs" about={"LLM API"} proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "LLM API", "chat completion", "OpenAI compatible"]} datePublished="2026-05-06T00:00:00Z" dateModified="2026-05-07T00:00:00Z" />

Build conversational AI applications using Eden AI's OpenAI-compatible chat completions endpoint.

## Overview

Eden AI V3 provides full OpenAI API compatibility with multi-provider support. The endpoint follows OpenAI's exact format, making it a drop-in replacement.

**Endpoint:**

```
POST /v3/chat/completions
```

**Note:** Streaming is optional. When enabled, responses are delivered via Server-Sent Events (SSE). See [Streaming](/v3/llms/streaming) for streaming examples.

## Model Format

Use the simplified model string format for LLM:

```
provider/model
```

**Examples:**

* `openai/gpt-4`
* `anthropic/claude-sonnet-4-5`
* `google/gemini-2.5-flash`
* `cohere/command-r-plus`

## Basic Chat Completion

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.edenai.run/v3/chat/completions"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  payload = {
      "model": "openai/gpt-4",
      "messages": [
          {"role": "user", "content": "Hello! How are you?"}
      ]
  }

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()
  print(result["choices"][0]["message"]["content"])
  ```

  ```javascript JavaScript theme={null}
  const url = 'https://api.edenai.run/v3/chat/completions';
  const headers = {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  };

  const payload = {
    model: 'openai/gpt-4',
    messages: [{role: 'user', content: 'Hello!'}]
  };

  const response = await fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(payload)
  });

  const result = await response.json();
  console.log(result.choices[0].message.content);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.edenai.run/v3/chat/completions \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-4",
      "messages": [{"role": "user", "content": "Hello!"}]
    }'
  ```
</CodeGroup>

## Multi-Turn Conversations

Build conversations with message history:

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.edenai.run/v3/chat/completions"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  payload = {
      "model": "anthropic/claude-sonnet-4-5",
      "messages": [
          {"role": "user", "content": "What is the capital of France?"},
          {"role": "assistant", "content": "The capital of France is Paris."},
          {"role": "user", "content": "What's the population?"}
      ]
  }

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()
  print(result["choices"][0]["message"]["content"])
  ```
</CodeGroup>

## System Messages

Guide the model's behavior with system messages:

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.edenai.run/v3/chat/completions"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  payload = {
      "model": "openai/gpt-4",
      "messages": [
          {
              "role": "system",
              "content": "You are a helpful assistant that speaks like a pirate."
          },
          {
              "role": "user",
              "content": "Tell me about artificial intelligence."
          }
      ]
  }

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()
  print(result["choices"][0]["message"]["content"])
  ```
</CodeGroup>

## Temperature and Parameters

Control response creativity and behavior:

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.edenai.run/v3/chat/completions"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  payload = {
      "model": "openai/gpt-4",
      "messages": [
          {"role": "user", "content": "Write a creative story about a robot."}
      ],
      "temperature": 0.9,  # Higher = more creative (0-2)
      "max_tokens": 500    # Limit response length
  }

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()
  print(result["choices"][0]["message"]["content"])
  ```
</CodeGroup>

## Available Parameters

| Parameter           | Type    | Default  | Description                           |
| ------------------- | ------- | -------- | ------------------------------------- |
| `model`             | string  | Required | Model string (e.g., `openai/gpt-4`)   |
| `messages`          | array   | Required | Conversation messages                 |
| `stream`            | boolean | false    | Enable streaming (uses SSE when true) |
| `temperature`       | float   | 1.0      | Randomness (0-2)                      |
| `max_tokens`        | integer | -        | Maximum response tokens               |
| `top_p`             | float   | 1.0      | Nucleus sampling threshold            |
| `frequency_penalty` | float   | 0.0      | Penalize repeated tokens (-2 to 2)    |
| `presence_penalty`  | float   | 0.0      | Penalize topic repetition (-2 to 2)   |
| `fallbacks`         | array   | -        | Backup models tried if `model` fails. |

<Tip>
  For details on the `fallbacks` field, see [Fallback](/v3/general/fallback).
</Tip>

## Response Format

Standard JSON response:

```json theme={null}
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm doing well, thank you for asking."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 15,
    "total_tokens": 27
  }
}
```

## Available Models

For the full list of supported models and their capabilities (PDF support, reasoning, web search, tool calling), see [List LLM Models](/v3/llms/listing-models).

## OpenAI Python SDK Integration

Use Eden AI with the OpenAI SDK:

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

  # Point to Eden AI endpoint
  client = OpenAI(
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  # Use any provider through OpenAI SDK
  response = client.chat.completions.create(
      model="anthropic/claude-sonnet-4-5",
      messages=[{"role": "user", "content": "Hello!"}]
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="First Expert Model Call" icon="bolt" href="/v3/quickstart/first-expert-model-call">
    Try OCR, image, and audio features with the Expert Models endpoint
  </Card>

  <Card title="LLMs vs Expert Models" icon="book-open" href="/v3/overview/llms-vs-expert-models">
    Understand when to use each endpoint
  </Card>
</CardGroup>
