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

# Make your first request

> Create an API key, call a model with cURL, Python, or TypeScript, and find the request in your console.

Create a key, send a request, and check its cost. Already have a key? Start at step 2.

## 1. Create an API key

Sign in to the [console](https://impossibl.com/dashboard). Follow onboarding, or open **api keys → new** in your workspace. Copy the key when it is shown and check that the workspace has credits.

Set it in the terminal where you will run the example:

```bash theme={null}
export IMPOSSIBL_API_KEY="your-impossibl-api-key"
```

Keep the key on your server or local machine, never in browser code. An agent can use [API registration](/docs/agent-quickstart) instead.

## 2. Send a request

Choose one tab. `openai/gpt-4o-mini` is a small text model used for this first call; you can replace it with another text model from the [catalog](/docs/models).

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl --fail-with-body https://api.impossibl.com/v1/chat/completions \
      -H "Authorization: Bearer $IMPOSSIBL_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "openai/gpt-4o-mini",
        "messages": [{"role": "user", "content": "Write a one-sentence welcome for a notes app."}],
        "max_tokens": 128
      }'
    ```

    The answer is in `choices[0].message.content`.

    <Accordion title="Example response">
      Text and token counts vary. This response is abbreviated:

      ```json theme={null}
      {
        "choices": [{
          "message": {
            "role": "assistant",
            "content": "Welcome to your space for notes and ideas."
          },
          "finish_reason": "stop"
        }],
        "usage": {
          "prompt_tokens": 20,
          "completion_tokens": 10,
          "total_tokens": 30
        }
      }
      ```
    </Accordion>
  </Tab>

  <Tab title="Python">
    Install the SDK:

    ```bash theme={null}
    python -m pip install openai
    ```

    Save this as `quickstart.py`:

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

    client = OpenAI(
        base_url="https://api.impossibl.com/v1",
        api_key=os.environ["IMPOSSIBL_API_KEY"],
    )

    response = client.chat.completions.create(
        model="openai/gpt-4o-mini",
        messages=[{"role": "user", "content": "Write a one-sentence welcome for a notes app."}],
        max_tokens=128,
    )
    print(response.choices[0].message.content)
    ```

    Run it in the terminal where you exported the key:

    ```bash theme={null}
    python quickstart.py
    ```
  </Tab>

  <Tab title="TypeScript">
    Use Node.js 24 or later for this example and install the SDK:

    ```bash theme={null}
    npm install openai
    ```

    Save this as `quickstart.mts`:

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

    const client = new OpenAI({
      baseURL: "https://api.impossibl.com/v1",
      apiKey: process.env.IMPOSSIBL_API_KEY,
    });

    const response = await client.chat.completions.create({
      model: "openai/gpt-4o-mini",
      messages: [{ role: "user", content: "Write a one-sentence welcome for a notes app." }],
      max_tokens: 128,
    });
    console.log(response.choices[0].message.content);
    ```

    Run it in the terminal where you exported the key:

    ```bash theme={null}
    node quickstart.mts
    ```
  </Tab>
</Tabs>

## 3. Find your request

Open **logs** in the [console](https://impossibl.com/dashboard). Select your request to see its status, tokens, latency, and cost. Make sure you are viewing the workspace that owns the API key.

<Accordion title="Read the latest request through the API">
  You can also read the latest request through the API:

  ```bash theme={null}
  curl --fail-with-body "https://api.impossibl.com/v1/requests?limit=1" \
    -H "Authorization: Bearer $IMPOSSIBL_API_KEY"
  ```
</Accordion>

## If the request fails

<Accordion title="Troubleshoot your first request">
  | What you see           | What to check                                                                                                    |
  | ---------------------- | ---------------------------------------------------------------------------------------------------------------- |
  | `401`                  | The environment variable contains an active impossibl key, and you are running in the terminal where you set it. |
  | `402`                  | The key's workspace has enough credits for the request. [Add credits](/docs/billing#topping-up).                      |
  | `403 billing_required` | The selected model requires purchased credits. Use the example model or make a credit purchase.                  |
  | `404`                  | Use the full model ID from [the live catalog](/docs/models), and keep `/v1` in the OpenAI SDK base URL.               |
  | `502` or `503`         | Read the error message and [troubleshoot the provider failure](/docs/errors).                                         |
</Accordion>

Next: [stream the answer](/docs/streaming) or [connect your preferred SDK](/docs/integrations).
