HTTP API

tokn$ · OpenAI-compatible surface

Point any OpenAI SDK at our gateway. You choose the model string per request; billing follows metered usage at roughly 60% of typical list per token for eligible pools.

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-4oOpenAI GPT-4o
gpt-4o-miniOpenAI GPT-4o mini
gpt-4-turboOpenAI GPT-4 Turbo
claude-3-5-sonnet-20241022Anthropic Claude 3.5 Sonnet
claude-3-opus-20240229Anthropic Claude 3 Opus
claude-3-haiku-20240307Anthropic Claude 3 Haiku
gemini-1.5-pro-latestGoogle Gemini 1.5 Pro
gemini-1.5-flash-latestGoogle Gemini 1.5 Flash
amazon.titan-text-express-v1AWS 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.