Base URL
https://api.credex.ai/v1
Override with NEXT_PUBLIC_CREDEX_API_URL in your deployment; default in repo points at the public gateway host.
Authentication
Send your issued gateway key on every request (same header shape as OpenAI):
Authorization: Bearer <TOKN_API_KEY>
Primary routes
POST /v1/chat/completions— streaming and non-streaming JSON bodies match OpenAI.POST /v1/completions— legacy text completions (where upstream still exposes them).GET /v1/models— capability discovery; filter client-side to the providers you enabled for your key.
Model names (examples)
Pass these as the JSON model field. Upstream availability depends on live pool inventory.
| Model id (example) | Family |
|---|---|
| gpt-4o | OpenAI GPT-4o |
| gpt-4o-mini | OpenAI GPT-4o mini |
| gpt-4-turbo | OpenAI GPT-4 Turbo |
| claude-3-5-sonnet-20241022 | Anthropic Claude 3.5 Sonnet |
| claude-3-opus-20240229 | Anthropic Claude 3 Opus |
| claude-3-haiku-20240307 | Anthropic Claude 3 Haiku |
| gemini-1.5-pro-latest | Google Gemini 1.5 Pro |
| gemini-1.5-flash-latest | Google Gemini 1.5 Flash |
| amazon.titan-text-express-v1 | AWS Bedrock Titan (example) |
Chat completion (curl)
curl https://api.credex.ai/v1/chat/completions \
-H "Authorization: Bearer $TOKN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{ "role": "user", "content": "Hello from tokn$" }]
}'Node (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TOKN_API_KEY,
baseURL: "https://api.credex.ai/v1",
});
const res = await client.chat.completions.create({
model: "claude-3-5-sonnet-20241022",
messages: [{ role: "user", content: "Ping" }],
});Errors
401— missing/invalid key.402— insufficient metered balance for this key.429/502— upstream or pool saturation; retry with backoff.
This page tracks the product contract for integrators. For database fields (e.g. profiles.playground_credits_usd) see Supabase migrations in supabase/migrations.