Quickstart
Get a key, then make a first request with curl, Python or TypeScript.
1. Get a key
A person does this step once. It needs an email click and a card.
- Sign up at plaingateway.com/signup with email or Google. Email sign-up sends a confirmation link; click it.
- Add at least $5 USD by card. Today, the first top-up of at least $5 USD adds $5 USD in bonus credit.
- Open /settings/keys, press New key, and copy the key. It starts with
sk-pg-v1-and is shown only once. - Keep the key in an environment variable on your server, never in a browser or a repository:
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.
3. Send a request with curl
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):
{
"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.
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 USD5. TypeScript
Install the OpenAI SDK with npm install openai.
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 page lists every request.
7. Read an error
Errors are JSON, and error.code is the HTTP status:
{ "error": { "message": "User not found.", "code": 401 } }401 means a bad key and 402 means the balance is too low. Errors lists every status.