Start here
Two reading paths through the Cruxy API: the whole API in nine pages, and building an agent with tools, structured output, memory, and rules.
There are two paths here. Each step names one page and what you take from it. The pages build on each other, so read a path in order the first time; after that, each page stands on its own as a reference.
- The API in nine pages goes from your first call to running in production.
- Build an agent is for when the model has to act: call your functions, return data your code can parse, and remember.
The API in nine pages
Make your first call
Quickstart takes you from an empty terminal to your first model response: you get an API key with device login, then send a chat request to the
cantotier.Choose a tier
Choosing a tier compares the tiers you pass as
model(canto,saga, andepos) by profile, output cap, and how each one reasons by default, and shows how to read the live catalog fromGET /api/v1/modelsinstead of hardcoding it.Hold a conversation
Chat documents
POST /api/v1/chat, the OpenAI-compatible chat completion: the request options, a single JSON completion or a Server-Sent Events stream, thecruxyblock, and usage.Let the model call your functions
Tutorial: build a tool-using agent builds on the same endpoint. You describe two functions, run the calls the model returns, send the results back, and loop on
finish_reasonuntil the model answers.Answer from your own documents
Retrieval-augmented generation is a cookbook recipe that chains three endpoints: embeddings for a first-pass search, rerank to sharpen the shortlist, and chat to write the answer.
Screen content
Moderations checks text against the content-safety categories with the
cruxy-guardmodel and returns an overallflaggedresult.Handle failures
Errors and retries defines the error envelope, lists every error code, and says which failures to retry and how long to wait, so your client branches on the stable
code, never on the wording of the message.Run it reliably
Reliability puts the production rules in one place: the per-tier deadlines, which failures to retry,
Idempotency-Key, how to tell a finished stream from a failed one, and where to check platform status.Know the limits
Known limitations lists what the API does not do today, such as reporting a reasoning-token count or running a non-streaming call past 90 seconds, and the workaround for each.
Build an agent
An agent is a loop: the model asks for a function call, your code runs it and sends the result back, and the model continues until it has an answer. This path assumes you have made a chat call; if not, start with the first three steps above.
Describe your functions
Define tools shows how to describe each function in the
toolsarray with a JSON Schema for its arguments, howtool_choicecontrols when the model calls one, and why tools are billed as input.Run the calls the model returns
Handle tool calls covers the other half: read the tool calls on the response, run each function, send every result back by
tool_call_id, and repeat untilfinish_reasonisstop.Put the loop together
Tutorial: build a tool-using agent builds a working TypeScript agent from those two pages: two tools, their handlers, and the loop on
finish_reason, with the reasons the loop is shaped the way it is.Get answers your code can parse
Ask for structured output explains
response_format: send a JSON schema to constrain the output, read which tiers support it fromGET /api/v1/models, and handle output that does not match.Let the agent remember
Memory lets chat recall stored facts and capture new ones. It is off for a developer API key until a request opts in, so read Opt in from a developer key before you rely on it.
Give it standing instructions
Standing rules injects your organization's rules into chat as defaults. Like memory, rules are off for a developer key unless you opt in, per request or once on the key.
Make the loop survive failures
Reliability matters more in a loop, where one failed request stalls the whole task: the per-tier deadlines, which failures to retry,
Idempotency-Key, and how to tell a finished stream from a failed one.
Next steps
Cookbook has more recipes that combine endpoints to finish a real job, and API Reference lists every endpoint with its exact request and response shape.
Working from a terminal instead?
Get started with the CLI installs Cruxy Code, the
cruxy coding agent, and signs it in with the same device login.
Moving code that already calls OpenAI?
Migrate from OpenAI changes the base URL, the
key, and model, and
OpenAI SDK compatibility says what
carries over.