Developer API

Build with OpenMock.

An OpenAI-compatible simulated AI API. Sign in with Google, copy your API key, and start building without provisioning a real model or paying for inference.

Quickstart

1. Sign in with Google. Your account is created automatically and receives the configured starting credit balance.

2. Copy your API key. Your full openmock_live_... key is shown once. If you lose it, revoke it and generate a new one.

3. Set your API key.

export openmock_live_API_KEY="openmock_live_xxxxx"

4. Make your first request.

curl https://openmock.vercel.app/api/v1/chat/completions \
  -H "Authorization: Bearer $openmock_live_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mock-fast",
    "messages": [{"role":"user","content":"Hello!"}]
  }'

Authentication

All /v1 endpoints that perform model operations require a Bearer API key. The model discovery endpoint is public.

Authorization: Bearer openmock_live_xxxxxxxxxxxxxxxxx
Keep your key private. Store it server-side. Never commit it to Git, expose it in browser code, or put it in a public client bundle.

Models

These are simulated models. They do not call OpenAI, Anthropic, Gemini, or another real LLM provider.

ModelLatencyCreditsMax output
mock-fast~50–150ms1,000
mock-smart~400–900ms2,000
mock-reasoner~1–2.5s4,000
mock-unstable~200ms–2sConfigurable

To discover models programmatically:

curl https://openmock.vercel.app/api/v1/models

Chat completions

POST /api/v1/chat/completions

Supported request fields include model, messages, temperature, max_tokens, and stream.

{
  "model": "mock-smart",
  "messages": [
    {"role": "system", "content": "You are helpful."},
    {"role": "user", "content": "Give me a startup idea."}
  ],
  "temperature": 0.7,
  "max_tokens": 500,
  "stream": false
}

Responses use an OpenAI-compatible shape:

{
  "id": "chatcmpl_mock_abc123",
  "object": "chat.completion",
  "created": 1788500000,
  "model": "mock-smart",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "A simulated response..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 85,
    "total_tokens": 127
  }
}

Streaming

Set stream: true to receive Server-Sent Events compatible with OpenAI streaming clients.

{
  "model": "mock-smart",
  "messages": [{"role":"user","content":"Tell me a story"}],
  "stream": true
}

The stream ends with:

data: [DONE]

Streaming does not bypass credit accounting.

Credits & token usage

The Sandbox uses an approximate token counter rather than a real model tokenizer. Simulated token counts are used consistently for usage and credits.

Example

300 simulated tokens × the mock-smart 2× multiplier = 600 credits.

Successful requests are charged. Authentication failures, validation failures, unknown models, and insufficient-credit requests are not charged. Simulated model failures are not charged by default.

Errors

Errors use a consistent OpenAI-style structure.

{
  "error": {
    "message": "Insufficient credits",
    "type": "insufficient_credits",
    "code": "insufficient_credits"
  }
}
HTTPCodeMeaning
400invalid_request_errorInvalid request
401authentication_errorMissing, invalid, or revoked key
402insufficient_creditsNot enough credits
404model_not_foundUnknown model
429rate_limit_errorRate limit exceeded
500server_errorServer/simulated failure
503service_unavailableAPI temporarily disabled

Every API response also includes an x-request-id header for debugging.

SDK examples

JavaScript / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.openmock_live_API_KEY,
  baseURL: "https://openmock.vercel.app/api/v1",
});

const response = await client.chat.completions.create({
  model: "mock-smart",
  messages: [
    { role: "user", content: "Give me a hackathon project idea." }
  ],
});

console.log(response.choices[0].message.content);

Python

from openai import OpenAI

client = OpenAI(
    api_key="openmock_live_xxxxxxxxx",
    base_url="https://openmock.vercel.app/api/v1",
)

response = client.chat.completions.create(
    model="mock-smart",
    messages=[
        {"role": "user", "content": "Give me a hackathon project idea."}
    ],
)

print(response.choices[0].message.content)

cURL

curl https://openmock.vercel.app/api/v1/chat/completions \
  -H "Authorization: Bearer openmock_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mock-fast",
    "messages": [{"role":"user","content":"Hello!"}]
  }'