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

# Chat Completions

> Generate text with chat, code, reasoning, and vision models.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

The chat completions endpoint powers text generation across Chat, Code, Reasoning, and Vision models. It supports streaming, system prompts, multi-turn conversations, and image inputs for vision-capable models.

## Endpoint

```
POST https://api.runcrate.ai/v1/chat/completions
```

## Basic Usage

<CodeGroup>
  ```bash curl theme={"theme":"github-dark"}
  curl https://api.runcrate.ai/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer rc_live_YOUR_API_KEY" \
    -d '{
      "model": "deepseek-ai/DeepSeek-V3",
      "messages": [
        {"role": "user", "content": "Explain quantum computing in simple terms"}
      ],
      "max_tokens": 512,
      "temperature": 0.7
    }'
  ```

  ```python Python theme={"theme":"github-dark"}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.runcrate.ai/v1",
      api_key="rc_live_YOUR_API_KEY",
  )

  response = client.chat.completions.create(
      model="deepseek-ai/DeepSeek-V3",
      messages=[
          {"role": "user", "content": "Explain quantum computing in simple terms"}
      ],
      max_tokens=512,
      temperature=0.7,
  )
  print(response.choices[0].message.content)
  ```

  ```javascript JavaScript theme={"theme":"github-dark"}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.runcrate.ai/v1",
    apiKey: "rc_live_YOUR_API_KEY",
  });

  const response = await client.chat.completions.create({
    model: "deepseek-ai/DeepSeek-V3",
    messages: [
      { role: "user", content: "Explain quantum computing in simple terms" }
    ],
    max_tokens: 512,
    temperature: 0.7,
  });
  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

## Streaming

Enable real-time token streaming with `stream: true`:

```python theme={"theme":"github-dark"}
stream = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",
    messages=[{"role": "user", "content": "Write a poem"}],
    stream=True,
)
for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="")
```

## Vision Models

Vision-capable models accept images in the message content. Send images as URLs or base64:

```python theme={"theme":"github-dark"}
response = client.chat.completions.create(
    model="google/gemini-2.5-flash",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is in this image?"},
                {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}},
            ],
        }
    ],
)
```

Vision-capable models include Gemini 2.5, Llama 4 Maverick, Gemma 3, GPT-4o, and others marked with "Vision" in the [Model Catalog](/models/model-catalog).

## Reasoning Models

Reasoning models (DeepSeek-R1, QwQ, etc.) produce chain-of-thought output. The reasoning steps appear in the `reasoning_content` field of the streamed response delta, separate from the final answer in `content`.

## Parameters

| Parameter     | Type    | Default  | Description                                     |
| ------------- | ------- | -------- | ----------------------------------------------- |
| `model`       | string  | required | Model ID (e.g., `deepseek-ai/DeepSeek-V3`)      |
| `messages`    | array   | required | Conversation messages with `role` and `content` |
| `max_tokens`  | integer | varies   | Maximum tokens to generate                      |
| `temperature` | number  | 0.7      | Randomness (0 = deterministic, 2 = very random) |
| `stream`      | boolean | false    | Enable streaming responses                      |
| `top_p`       | number  | 1.0      | Nucleus sampling threshold                      |

### Message Roles

| Role        | Purpose                                   |
| ----------- | ----------------------------------------- |
| `system`    | Sets the model's behavior and personality |
| `user`      | The user's input                          |
| `assistant` | Previous model responses (for multi-turn) |

## Popular Chat Models

| Model                       | Context | Best For                        |
| --------------------------- | ------- | ------------------------------- |
| `deepseek-ai/DeepSeek-V3`   | 128K    | General purpose, cost-effective |
| `anthropic/claude-4-sonnet` | 200K    | Reasoning, analysis, coding     |
| `google/gemini-2.5-flash`   | 1M      | Fast, multimodal, long context  |
| `meta-llama/Llama-4-Scout`  | 128K    | Multilingual, efficient         |
| `Qwen/Qwen3-Max`            | 128K    | Reasoning, multilingual         |
