---
title: "Quickstart"
description: "Sign up with no card, create a key, send a test call, then add credits when you want more."
---

# Quickstart

## 1. Get a key

A person does this step once. It needs no card.

1. Sign up at [plaingateway.com/signup](https://plaingateway.com/signup) with email or Google. Email sign-up sends a confirmation link; click it.
2. Open [/settings/keys](https://plaingateway.com/settings/keys), press **New key**, and copy the key. It starts with `sk-pg-v1-` and is shown only once.
3. Keep the key in an environment variable on your server, never in a browser or a repository:

```sh
export PLAINGATEWAY_API_KEY="sk-pg-v1-..."
```

## 2. Use the base URL

| Client | Base URL |
|---|---|
| OpenAI-compatible clients and plain HTTP | `https://api.plaingateway.com/api/v1` |
| Anthropic SDK (it appends `/v1/messages`) | `https://api.plaingateway.com/api` |

Send the key as `Authorization: Bearer $PLAINGATEWAY_API_KEY`.
Model ids look like `openai/gpt-5.6-luna`. See every id and price on [Models](https://plaingateway.com/models).

## 3. Send a test call with curl

Requests are paid from your balance. New accounts may get a small starting credit.
Add credits on [/settings/credits](https://plaingateway.com/settings/credits) when you want more.

```sh
curl https://api.plaingateway.com/api/v1/chat/completions \
  -H "Authorization: Bearer $PLAINGATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-5.6-luna", "messages": [{"role": "user", "content": "Say hello in five words."}], "max_tokens": 32}'
```

The answer (values vary):

```json
{
  "id": "gen-6f2d0c5e9a1b4c7d8e3f2a10",
  "object": "chat.completion",
  "model": "openai/gpt-5.6-luna",
  "provider": "OpenAI",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": { "role": "assistant", "content": "Hello! How are you today?" }
    }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 11, "total_tokens": 23, "cost": 0.0000156 }
}
```

## 4. Python

Install the OpenAI SDK with `pip install openai`.

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.plaingateway.com/api/v1",
    api_key=os.environ["PLAINGATEWAY_API_KEY"],
)
r = client.chat.completions.create(
    model="openai/gpt-5.6-luna",
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(r.choices[0].message.content)
print(r.usage.cost)  # the charge in USD
```

## 5. TypeScript

Install the OpenAI SDK with `npm install openai`.

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.plaingateway.com/api/v1",
  apiKey: process.env.PLAINGATEWAY_API_KEY,
});
const r = await client.chat.completions.create({
  model: "openai/gpt-5.6-luna",
  messages: [{ role: "user", content: "Say hello in five words." }],
});
console.log(r.choices[0].message.content);
```

## 6. See the cost of each response

Every response carries `X-PG-Host`, which names the host that served it. A non-streamed response also carries `X-PG-Cost-USD`, the charge in USD.
Add `-i` to the curl command to see them. On a stream, the cost is `usage.cost` in the final usage chunk.
`usage.cost` in the body holds the same charge. The [Activity](https://plaingateway.com/activity) page lists every request.

## 7. Read an error

Errors are JSON, and `error.code` is the HTTP status:

```json
{ "error": { "message": "User not found.", "code": 401 } }
```

401 means a bad key and 402 means the balance is too low. [Errors](../api/errors.md) lists every status.
