Get started
Quickstart
Three steps to call AI through KONG API AI: create an account, create a key, and send your first request with cURL, Python or Node.js.
1. Create an account
Open the sign-up page and enter an email and a password. Every account starts on the Free plan. No card is needed.
2. Create a key
In the console, open API Keys and create a key. A key starts with gw_live_ or gw_test_.
3. Send your first request
The base URL of the API is:
https://kongapiai.com/v1Replace gw_live_… with your key and MODEL_ID with a model from Models and prices.
curl https://kongapiai.com/v1/chat/completions \
-H "Authorization: Bearer gw_live_…" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"model": "MODEL_ID", "messages": [{"role": "user", "content": "Hello"}]}'# pip install openai
from openai import OpenAI
import uuid
client = OpenAI(base_url="https://kongapiai.com/v1", api_key="gw_live_…")
r = client.chat.completions.create(
model="MODEL_ID",
messages=[{"role": "user", "content": "Hello"}],
extra_headers={"Idempotency-Key": str(uuid.uuid4())},
)
print(r.choices[0].message.content)// npm install openai
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://kongapiai.com/v1", apiKey: "gw_live_…" });
const r = await client.chat.completions.create(
{ model: "MODEL_ID", messages: [{ role: "user", content: "Hello" }] },
{ headers: { "Idempotency-Key": crypto.randomUUID() } },
);
console.log(r.choices[0].message.content);Why send an Idempotency-Key
Idempotency-Key is an ID you generate for each request. If the network drops and your code sends the same request again with the same ID, KONG API AI does not call the provider a second time and does not charge twice. Details are on the API page.
Next steps
- Put a limit on each key: Limits and routing.
- Put the key into Claude Code, Codex or Cursor: Set up your tool.
- Handle errors in code: Errors.