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

# Quickstart

> Send your first chat request with MaxAPI.

This guide uses the OpenAI-compatible Chat Completions API. Before you begin, you need:

* A MaxAPI account and API key.
* An available model ID from the console.
* `curl`, Python 3.8+, or Node.js 18+.

<Steps>
  <Step title="Create an API key">
    Sign in to MaxAPI and create an API key. Set it as an environment variable in your current terminal:

    ```bash theme={null}
    export MAXAPI_API_KEY="YOUR_API_KEY"
    ```

    <Warning>
      Store the key immediately. Never expose it in browser code, mobile applications, or public repositories.
    </Warning>
  </Step>

  <Step title="Send a request">
    Replace `YOUR_MODEL_ID` with a model ID from the console. Install the `openai` package before you use the Python or Node.js example.

    <CodeGroup>
      ```bash Python theme={null}
      python -m pip install openai
      ```

      ```bash Node.js theme={null}
      npm install openai
      ```
    </CodeGroup>

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.maxapi.ai/v1/chat/completions \
        -H "Authorization: Bearer $MAXAPI_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "YOUR_MODEL_ID",
          "messages": [
            {"role": "user", "content": "Introduce MaxAPI in one sentence."}
          ]
        }'
      ```

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

      client = OpenAI(
          api_key=os.environ["MAXAPI_API_KEY"],
          base_url="https://api.maxapi.ai/v1",
      )

      response = client.chat.completions.create(
          model="YOUR_MODEL_ID",
          messages=[
              {"role": "user", "content": "Introduce MaxAPI in one sentence."}
          ],
      )

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

      ```javascript Node.js theme={null}
      import OpenAI from "openai";

      const client = new OpenAI({
        apiKey: process.env.MAXAPI_API_KEY,
        baseURL: "https://api.maxapi.ai/v1",
      });

      const response = await client.chat.completions.create({
        model: "YOUR_MODEL_ID",
        messages: [
          { role: "user", content: "Introduce MaxAPI in one sentence." },
        ],
      });

      console.log(response.choices[0].message.content);
      ```
    </CodeGroup>
  </Step>

  <Step title="Read the response">
    The generated text is available at `choices[0].message.content`.
  </Step>
</Steps>

## Troubleshooting

| Symptom                          | Check                                                                                         |
| -------------------------------- | --------------------------------------------------------------------------------------------- |
| `401` response                   | Confirm that `MAXAPI_API_KEY` is set and the header includes the `Bearer` prefix              |
| `404` response                   | Use `https://api.maxapi.ai/v1` for the SDK base URL or the complete path for a direct request |
| Model not found                  | Copy the model ID from the console instead of using its display name                          |
| Request does not finish promptly | Check whether the model uses an asynchronous task endpoint                                    |

## Next steps

<CardGroup cols={2}>
  <Card title="Choose an API format" icon="shuffle" href="/en/guides/choose-api">
    Decide between an OpenAI-compatible and provider-native format.
  </Card>

  <Card title="Authentication" icon="key" href="/en/guides/authentication">
    Manage API keys safely.
  </Card>

  <Card title="Asynchronous tasks" icon="clock" href="/en/guides/async-tasks">
    Generate images, videos, and music.
  </Card>
</CardGroup>
