Docs

Quickstart

MarketAi speaks the OpenAI API. Point any OpenAI SDK at MarketAi, use your mk- key, and pick a model id from the market.

1. Create a key

Sign up, open Dashboard → API keys and create a key. It is shown once, so store it in your secret manager.

2. Make a request

curl https://your-marketai-domain/v1/chat/completions \
  -H "Authorization: Bearer $MARKETAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-5-mini", "messages": [{"role": "user", "content": "Hello"}]}'
// JavaScript (openai package)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://your-marketai-domain/v1", apiKey: process.env.MARKETAI_KEY });
const stream = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4.5", stream: true,
  messages: [{ role: "user", content: "Write a haiku about markets" }],
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");

Endpoints

GET /v1/modelsEvery model id with its price per million tokens
POST /v1/chat/completionsChat, with stream: true for server-sent events
POST /v1/images/generationsOne image per request (n = 1), returned as b64_json

Costs in every reply

Each response includes usage.cost, the credits charged for it, and marketai_request_id, which matches the request log in your dashboard. A streamed reply reports its cost in the last chunk.

Errors

401Missing, invalid or revoked key
402insufficient_credits: top up to continue
404model_not_found: check the id in the market
429Too many requests a minute on one key
502The model provider failed. You are not charged; retry or pick another model

For AI agents

Give your agent https://your-marketai-domain/llms.txt. It describes every endpoint in one page.