Models
Failure Tempest 1All modelsStatus
Research
OverviewAPI fusionEvaluation
Developers
DocumentationConsoleChangelog
Company
PricingEnterpriseAboutSecurityContact
Account
Sign inCreate account
Docs/SDKs
Documentation

Bring your own client.

There is no Failure SDK, on purpose. The API is OpenAI-compatible, so the OpenAI SDKs and the tools built on them work by changing two settings.

The two settings

SettingValue
Base URLhttps://api.failure.fail/v1
API keyYour Failure API key from the Console

Then use a Failure model id, such as failure-tempest-1.

Python

pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.failure.fail/v1",
    api_key=os.environ["FAILURE_API_KEY"],
)

resp = client.chat.completions.create(
    model="failure-tempest-1",
    messages=[{"role": "user", "content": "Is 2^61 - 1 prime? Show the check."}],
)
print(resp.choices[0].message.content)
print(resp.usage)

Async works the same way:

import asyncio, os
from openai import AsyncOpenAI

client = AsyncOpenAI(base_url="https://api.failure.fail/v1", api_key=os.environ["FAILURE_API_KEY"])

async def main():
    resp = await client.chat.completions.create(
        model="failure-tempest-1-flash",
        messages=[{"role": "user", "content": "Three names for a model-merging lab."}],
    )
    print(resp.choices[0].message.content)

asyncio.run(main())

TypeScript / Node

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.failure.fail/v1",
  apiKey: process.env.FAILURE_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "failure-tempest-1",
  messages: [{ role: "user", content: "Is 2^61 - 1 prime? Show the check." }],
});
console.log(resp.choices[0].message.content);
console.log(resp.usage);

Environment variables

Both OpenAI SDKs read OPENAI_BASE_URL and OPENAI_API_KEY, which lets many existing tools switch over with no code change:

export OPENAI_BASE_URL="https://api.failure.fail/v1"
export OPENAI_API_KEY="$FAILURE_API_KEY"

Reading the extra fields

Three things are not in the OpenAI SDK types: delta.reasoning_content, usage.cost and the top-level tempest object. The SDKs keep unknown fields, so read them dynamically.

resp = client.chat.completions.create(model="failure-tempest-1", messages=msgs)
print(resp.usage.model_extra.get("cost"))   # USD
print(resp.model_extra.get("tempest"))      # task, difficulty, stage, cache, billed_usd
const resp: any = await client.chat.completions.create({ model: "failure-tempest-1", messages });
console.log(resp.usage.cost, resp.tempest);

Custom headers

Pass x-tempest-cache with extra_headers / default_headers in Python and headers / defaultHeaders in TypeScript. Examples in caching.

Other clients

Any client that lets you set an OpenAI-compatible base URL should work. If one does not, write to api@failure.fail with the client name and the error.