> ## 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](https://impossibl.com/docs/agent-quickstart.md) 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](https://impossibl.com/docs/models.md).

> [tab] 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] 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
> >   }
> > }
> > ```

> [tab] 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] 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
> ```

## 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] 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"
> ```

## If the request fails

> [accordion] 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](https://impossibl.com/docs/billing.md#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](https://impossibl.com/docs/models.md), and keep `/v1` in the OpenAI SDK base URL. |
> | `502` or `503` | Read the error message and [troubleshoot the provider failure](https://impossibl.com/docs/errors.md). |

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.