API

An OpenAI-compatible API.

SacredAI and Heretic in the familiar OpenAI format. Only the base URL and key change, and limits are shared with chat.

Your first request in a minute.

  1. Create a key

    In your account, under API keys. Two-factor authentication is required.

  2. Set the base URL

    https://sacredgpt.pro/v1, with the key sent as Bearer sg_live_…

  3. Pick a model

    sacredai-heretic or the free sacredgpt-auto

cURL
curl https://sacredgpt.pro/v1/chat/completions \
  -H "Authorization: Bearer $SACREDGPT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sacredai-heretic",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Official OpenAI SDKs work as they are.

No adapters: set the SacredGPT base URL and your key.

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://sacredgpt.pro/v1",
    api_key="sg_live_...",
)

response = client.chat.completions.create(
    model="sacredai-heretic",
    messages=[{"role": "user", "content": "Hello!"}],
)

print(response.choices[0].message.content)
TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://sacredgpt.pro/v1",
  apiKey: process.env.SACREDGPT_KEY,
});

const response = await client.chat.completions.create({
  model: "sacredai-heretic",
  messages: [{ role: "user", content: "Hello!" }],
});

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

Two models.

GET /v1/models lists the models available to your key.

SacredAI Heretic

sacredai-heretic

Direct answers with minimal refusals. 10 trial requests, then a chat plan.

SacredAI

sacredgpt-auto

The everyday model. Free, with a limit that renews on its own.

Streaming and tools.

Streaming

Add stream: true to get the reply in parts over Server-Sent Events.

Tools

Pass tools and tool_choice in the OpenAI format. Function calls come back in tool_calls.

Structured output

Use response_format for JSON Schema replies. Support depends on the current Heretic route.

TypeScript · streaming
const stream = await client.chat.completions.create({
  model: "sacredai-heretic",
  messages: [{ role: "user", content: "Explain this code" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Shared with chat

A key uses the same model limits as chat and Agent mode. They renew every 5 hours and every week.

When the limit runs out

You get a 429. The x-ratelimit-reset-* headers and GET /v1/usage show when the limit returns.

Rate

The server enforces RPM, TPM, and concurrent streams. They aren't configurable in the dashboard yet.

Errors.

Codes your application should handle.

HTTPCodeWhat happened
400invalid_requestInvalid request body or parameters
401invalid_api_keyThe key is invalid, expired, or lacks the required scope
403heretic_plan_requiredThe 10 free Heretic requests are used up; a chat plan is required
404model_not_foundThe model does not exist or is not available to this key
409idempotency_replayThis Idempotency-Key has already been used
413request_too_largeThe request is too large
429sacredai_limit_reached · heretic_limit_reachedThe 5-hour or 7-day limit is exhausted
429sacredai_concurrency_limit · heretic_concurrency_limitToo many simultaneous requests to the model
429rate_limit_exceeded · concurrent_stream_limitThe key's RPM, TPM, or stream limit is exceeded
502provider_errorTemporary model failure; retry the request
503model_provider_busyThe model is overloaded; retry in a minute
504model_timeoutThe model did not finish in time

API questions

Is the API billed separately?

No. The API is included in your chat plan: an ordinary key uses the same model limits as chat and Agent mode. There is no per-token price.

Are my requests stored?

API request content is not added to chat history. Only technical data for limits, billing, and security is kept. Heretic requests follow the current provider's retention terms.

How do I check my remaining limit?

GET /v1/usage with the usage:read scope returns the key's usage and the shared Heretic status. For sacredai-heretic, send /usage as the last message: the reply comes without a model call and uses no limit.

Does the server run my tools?

No. The model returns tool_calls; your code runs the function and sends the result back to the model.

Direct line

Found a bug? Show us.

Tell us what happened and what you expected. The page address and browser details help us reproduce it faster.