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

# Quickstart

> Use select open-weight models hosted by Relace

## Overview

In addition to our purpose-built code models, we host our set of preferred open-weight models for coding tasks. You can hit these models directly through our **OpenAI-compatible API**. For discounted reserve rates, reach out to [info@relace.ai](mailto:info@relace.ai).

All hosted models are served from `https://models.relace.ai` and authenticate with your regular Relace API key -- no separate setup, and any OpenAI SDK works by pointing it at our base URL.

| Model                  | Slug                                 | Context | Input      | Output      | Cached Input |
| ---------------------- | ------------------------------------ | ------- | ---------- | ----------- | ------------ |
| DeepSeek V4 Flash 0731 | `deepseek-ai/DeepSeek-V4-Flash-0731` | 1M      | \$0.14 / M | \$0.28 / M  | \$0.028 / M  |
| Kimi K3                | `moonshotai/kimi-k3`                 | 1M      | \$3.00 / M | \$15.00 / M | \$0.30 / M   |

## Prerequisites

* [Sign up](https://app.relace.ai) for a Relace account.
* Create an [API key](https://app.relace.ai/settings/api-keys).

<Steps>
  <Step title="List Available Models">
    The live up to date model catalog is available from the `/models` endpoint.

    ```bash theme={null}
    curl https://models.relace.ai/models \
      -H "Authorization: Bearer $RELACE_API_KEY"
    ```

    Each entry in the returned `data` array includes the model `id`, `context_length`, per-token `pricing`, and supported sampling parameters and features.
  </Step>

  <Step title="Call Chat Completions">
    Send requests to `/v1/chat/completions` with the model ID of your choice. The endpoint is OpenAI-compatible, so you can use the OpenAI SDK directly.

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

      client = OpenAI(
          api_key="[YOUR_API_KEY]",
          base_url="https://models.relace.ai/v1",
      )

      response = client.chat.completions.create(
          model="deepseek-ai/DeepSeek-V4-Flash-0731",
          messages=[
              {"role": "user", "content": "Write a binary search in Python."}
          ],
      )

      print(response.choices[0].message.content)
      ```

      ```typescript TypeScript theme={null}
      import OpenAI from "openai";

      const client = new OpenAI({
        apiKey: "[YOUR_API_KEY]",
        baseURL: "https://models.relace.ai/v1"
      });

      const response = await client.chat.completions.create({
        model: "deepseek-ai/DeepSeek-V4-Flash-0731",
        messages: [
          { role: "user", content: "Write a binary search in Python." }
        ]
      });

      console.log(response.choices[0].message.content);
      ```

      ```bash cURL theme={null}
      curl https://models.relace.ai/v1/chat/completions \
        -H "Authorization: Bearer $RELACE_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "deepseek-ai/DeepSeek-V4-Flash-0731",
          "messages": [
            {"role": "user", "content": "Write a binary search in Python."}
          ]
        }'
      ```
    </CodeGroup>

    Tool calling, JSON mode, structured outputs, and the standard sampling parameters (`temperature`, `top_p`, `stop`, etc.) work as they do with any OpenAI-compatible provider.
  </Step>

  <Step title="Stream Responses">
    Set `stream: true` to receive tokens as they are generated. Token usage is always reported in the final chunk of the stream.

    ```python theme={null}
    stream = client.chat.completions.create(
        model="moonshotai/kimi-k3",
        messages=[
            {"role": "user", "content": "Explain the actor model in one paragraph."}
        ],
        stream=True,
    )

    for chunk in stream:
        if chunk.choices and chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="")
        if chunk.usage:
            print(f"\n\nTokens used: {chunk.usage.total_tokens}")
    ```
  </Step>
</Steps>

## Usage

Hosted model usage is billed per token at the rates advertised in the [catalog](#list-available-models). Usage appears in your [dashboard](https://app.relace.ai) alongside your other Relace API usage.
