API

An API compatible with OpenAI and Anthropic

Chat Completions, Responses, Images and Messages on one key. This page has addresses, models, endpoints and errors; setup for Cursor, Claude Code, Codex and other IDEs is under Integrations.

01

Create a key

In your profile, API tab. The key starts with sk-slafy- and is shown once, so save it.

02

Choose a model

Model IDs are listed below and on the pricing page. For example, claude-sonnet-5-5.

03

Set the address and key

For the OpenAI format the address is https://slafy.co/v1, for Anthropic https://slafy.co. Pass the key as Bearer or x-api-key.

Base URL
https://slafy.co/v1
For the Anthropic SDK
https://slafy.co, the SDK adds /v1 itself
Key
Authorization: Bearer sk-slafy-… or x-api-key: sk-slafy-… header
Model list
GET /v1/models, prices on the Pricing page
Reasoning effort
reasoning_effort (reasoning.effort in Responses): low, medium, high, xhigh, max or ultra, the last one being the maximum for the selected model. If a model doesn't support a value, Slafy substitutes the closest one, and for models without effort settings it removes the parameter

OpenAI SDK

Python and Node.js, any model via Chat Completions

Python

from openai import OpenAI

client = OpenAI(base_url="https://slafy.co/v1", api_key="sk-slafy-your_key")
r = client.chat.completions.create(
    model="claude-sonnet-5-5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://slafy.co/v1", apiKey: process.env.SLAFY_API_KEY });
const r = await client.chat.completions.create({
  model: "gpt-6-luna",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);

Anthropic SDK

Python and Node.js, Claude models via Messages

Python

import anthropic

client = anthropic.Anthropic(base_url="https://slafy.co", api_key="sk-slafy-your_key")
m = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(m.content[0].text)

Node.js

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "https://slafy.co", apiKey: process.env.SLAFY_API_KEY });
const m = await client.messages.create({
  model: "claude-sonnet-5-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});
console.log(m.content[0].text);

curl

Check your key and model from the terminal

Chat Completions

curl https://slafy.co/v1/chat/completions \
  -H "Authorization: Bearer sk-slafy-your_key" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Hello"}]}'

Messages, streaming

curl https://slafy.co/v1/messages \
  -H "x-api-key: sk-slafy-your_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model": "claude-sonnet-5-5", "max_tokens": 512, "stream": true,
       "messages": [{"role": "user", "content": "Tell me a joke"}]}'

Image generation

The model draws inside its answer or through the Images API

One image costs $0.199, which is 500,000 balance tokens. Errors and rejected requests are free.

Ask the model to draw

Add the {"type": "image_generation"} tool to a Responses request. The model decides when to draw and returns the image in an image_generation_call item (base64 PNG in the result field). This is how Codex and agents built on the OpenAI SDK draw.

curl https://slafy.co/v1/responses \
  -H "Authorization: Bearer sk-slafy-your_key" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-6-astra", "input": "Draw an app icon: a blue whale, flat style",
       "tools": [{"type": "image_generation", "quality": "low"}]}'

GPT models can draw: gpt-6.1-sol, gpt-6.1-terra, gpt-6-astra, gpt-6-luna. The text tokens of the answer are added to the image price.

Images API

from openai import OpenAI
import base64

client = OpenAI(base_url="https://slafy.co/v1", api_key="sk-slafy-your_key")
r = client.images.generate(model="gpt-image-2.5-sunburst", prompt="A blue whale, flat style", size="1024x1024")
open("whale.png", "wb").write(base64.b64decode(r.data[0].b64_json))

The names gpt-image-2, gpt-image-1, dall-e-3 work too: Slafy sends them to gpt-image-2.5-sunburst. So ready-made scripts and skills written for OpenAI work without changes.

Models

IDs for the model field and the API formats each model works with. Prices are on the pricing page.

Anthropic
  • Claude Opus 5.5claude-opus-5-5chat/completions · responses · messages
  • Claude Sonnet 5.5claude-sonnet-5-5chat/completions · responses · messages
  • Claude Haiku 5.5claude-haiku-5-5chat/completions · responses · messages
  • Claude Fable 5.1claude-fable-5-1chat/completions · responses · messages
OpenAI
  • GPT-6.1 Solgpt-6.1-solchat/completions · responses · messages
  • GPT-6.1 Terragpt-6.1-terrachat/completions · responses
  • GPT-6 Astragpt-6-astrachat/completions · responses · messages
  • GPT-6 Lunagpt-6-lunachat/completions · responses · messages
  • GPT Image 2.5 Sunburstgpt-image-2.5-sunburstimages
Google
  • Gemini 4 Argongemini-4-argonchat/completions
  • Gemini 3.8 Flashgemini-3.8-flashchat/completions
xAI
  • Grok 4.7grok-4.7chat/completions · responses · messages
DeepSeek
  • DeepSeek V4 Prodeepseek-v4-prochat/completions
  • DeepSeek V4.1 Flash 1017deepseek-v4.1-flash-1017chat/completions
Moonshot AI
  • Kimi K3.1 Prokimi-k3.1-prochat/completions
Zhipu AI
  • GLM 5.3glm-5.3chat/completions · responses · messages
  • GLM 5.3 Flashglm-5.3-flashchat/completions · responses · messages

Endpoints

Method and pathFormat
POST /v1/chat/completionsOpenAI Chat Completions, streaming supported
POST /v1/responsesOpenAI Responses, streaming and the image_generation tool
POST /v1/messagesAnthropic Messages, streaming supported
POST /v1/messages/count_tokensAnthropic, token counting, free
POST /v1/images/generationsOpenAI Images, response in b64_json
POST /v1/images/editsOpenAI Images, multipart/form-data
GET /v1/modelsList of available models

Which model works with which endpoint is shown in pricing.

Errors

HTTPCodeWhat to do
401invalid_api_keyKey not found or disabled. Copy the full key from your profile.
402insufficient_balanceYou're out of tokens, top up your balance.
402key_limit_reachedThe key has hit its spending limit, raise the limit in the API tab.
404model_not_foundNo such model. Check the name with GET /v1/models.
429rate_limit_exceededToo many requests. Try again in a few seconds.
5xxupstream_errorModel-side failure, the request isn't charged. Try again.

Every response has a x-request-id header that you can use to find the request in your history.