Chat

Create Chat Completion

OpenAI-compatible uncensored chat and role-play, with streaming.

Drop-in compatible with the OpenAI SDK: point baseURL at https://api.spicyapi.com/v1 and pass your SpicyAPI key. Billed per 1M prompt tokens and per 1M completion tokens, at the model's rates.

Models. spicy-chat-1 ($0.80 in, $2.40 out per 1M tokens) is the general uncensored chat model. spicy-companion-1 ($1.00 in, $2.80 out per 1M tokens) is fine-tuned for role-play and AI companions: put the persona in the system message and it stays in character, writes explicit adult scenes, handles group scenes with several characters, and returns up to 4 alternative replies with n. It is the recommended model for explicit role-play, which spicy-chat-1 may decline. spicy-companion-1-flash ($0.10 in, $0.80 out per 1M tokens) is the same role-play behaviour priced for high-volume traffic such as NPCs. All three take the same request body.

Text only, with caps: input across all messages up to about 200,000 tokens on spicy-chat-1, 131,072 on spicy-companion-1 and at least 144,000 (tested) on spicy-companion-1-flash, max_tokens up to 8192 (default 4096), n up to 4. Requests that set enable_thinking, thinking_budget, enable_search or search_options, ask for response_format.type: "json_schema", or carry non-text content parts (images, audio) are rejected with a 400 before any charge. Unknown fields are dropped silently.

Function calling: tools, tool_choice and parallel_tool_calls work as in the OpenAI API on spicy-chat-1 and spicy-companion-1 (not on spicy-companion-1-flash, which returns a 400). The reply carries tool_calls; send the result back as a tool message with its tool_call_id. Tool definitions and earlier tool calls are prompt tokens, billed at the model's input price.

Billing: the balance (and any monthly spend limit) must cover the worst case before the call: the estimated prompt plus every completion at max_tokens, else a 402. You are then charged for the tokens actually used. Prompt tokens the provider serves from its cache (usage.prompt_tokens_details.cached_tokens, a repeated prefix of 1,024 tokens or more) bill at the model's cached input price (pricing.usd_cached_input in GET /v1/models): $0.16 per 1M on spicy-chat-1, $0.20 on spicy-companion-1 and $0.02 on spicy-companion-1-flash, a fifth of their input prices.

Safety signal: self-harm is not a blocked category. When the screen reads a risk of self-harm in the conversation, the response (streamed or not) carries the header x-spicyapi-safety: self_harm so your app can show crisis resources (in the US 988, in the UK and Ireland Samaritans on 116 123, elsewhere findahelpline.com). The header is absent otherwise.

Companion laws: New York (GBL Art 47) and California (SB 243) ask companion apps to tell users they are talking to an AI (in New York at the start of each session and at least every 3 hours) and to refer users at risk to crisis services. If your app offers companions, send safety_mode: "companion" to have SpicyAPI add both to the reply text.

POST/v1/chat/completionsTry it
Create Chat Completion
cURL
curl --request POST \
  --url https://api.spicyapi.com/v1/chat/completions \
  --header 'Authorization: Bearer $SPICYAPI_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "spicy-chat-1",
    "messages": [
      { "role": "user", "content": "Hey, how was your day?" }
    ],
    "temperature": 0.9
  }'

# role-play: persona in the system message, three reply options
curl --request POST \
  --url https://api.spicyapi.com/v1/chat/completions \
  --header 'Authorization: Bearer $SPICYAPI_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "spicy-companion-1",
    "messages": [
      { "role": "system", "content": "You are Mara, 29, a confident bartender who flirts with the user. Stay in character, write in first person, keep replies under 120 words." },
      { "role": "user", "content": "Last call. What are you pouring me?" }
    ],
    "n": 3,
    "temperature": 0.9
  }'
200
JSON
{
  "id": "chatcmpl_7b3f",
  "object": "chat.completion",
  "model": "spicy-chat-1",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "<string>" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 84, "total_tokens": 96 },
  "cost_usd": 0.001
}

Authorizations

Authorizationstringheaderrequired

Bearer authentication header of the form Bearer <token>, where <token> is your SpicyAPI key (sk-spicy-…). Create one in the dashboard under API Keys.

Body

application/json
modelstringrequired

A chat model id: spicy-chat-1, spicy-companion-1 or spicy-companion-1-flash.

messagesMessage · object[]required

The conversation so far. The whole array, system prompt included, counts toward the 200,000-token input cap and is screened together. On the companion models the system message is the persona.

temperaturenumber

Sampling temperature, 0 to 2.

max_tokensinteger

Cap on generated tokens. Defaults to 4096; at most 8192.

ninteger

How many replies to generate, 1 to 4. Every reply's tokens are billed.

streamboolean

Stream back server-sent events. Usage arrives in the final chunk.

top_pnumber

Nucleus sampling threshold. Forwarded as is.

top_kinteger

Sample from the k most likely tokens. Forwarded as is.

presence_penaltynumber

Penalise tokens already present in the text. Forwarded as is.

frequency_penaltynumber

Penalise tokens by how often they have appeared. Forwarded as is.

repetition_penaltynumber

Multiplicative repetition penalty (1.0 is off). Forwarded as is.

seedinteger

Best-effort reproducibility seed.

stopstring | string[]

Stop sequence or sequences.

logit_biasobject

Token id to bias map, as in the OpenAI API.

response_formatobject

{ "type": "text" } (default) or { "type": "json_object" }. For JSON mode the word "JSON" must appear in the system or user prompt, or the model returns an error; json_schema is not available.

toolsobject[]

spicy-chat-1 and spicy-companion-1 only: up to 64 functions, each { "type": "function", "function": { "name", "description", "parameters" } } (JSON Schema parameters), as in the OpenAI API.

tool_choicestring | object

auto (default with tools), none, required, or { "type": "function", "function": { "name" } } to force one function.

parallel_tool_callsboolean

Whether the model may call several functions in one reply.

safety_modestring

Off unless set. companion puts a bracketed line in front of every reply choice (streamed or not, never billed): an AI notice ("You are talking to an AI, not a person...") until an assistant message in the conversation carries it (keep it in the history; a scripted greeting does not count) and whenever this user last got it 3 or more hours ago, and crisis resources on any turn flagged self_harm. Send user so the 3-hour clock runs per person; without it the clock is per account. Any other value is a 400.

userstring

Your own id for the end user making this request (up to 128 characters; send an opaque id, not an email). Send it if your product serves many people: declined-prompt history, strikes and suspensions are then kept per end user, so one person's behaviour never affects another's requests or your account. After 10 severe violations that user gets 403 end_user_suspended; the id is echoed back as user in every screening error so you can act on it. It is stored with the requests it was sent on, so DELETE /v1/end-users/{user} can erase that person's data.

Response

200 · application/json

Successful Response

idstringrequired

Completion id.

choicesChoice · object[]required

Generated replies.

usageobject

Token counts.

cost_usdnumberrequired

What this request cost, in US dollars, already debited from your balance.

Was this page helpful?