Authorization: Bearer <key>. Keep it server-side.
Things to know before you call:
- Every generation is paid.
chat.completions,responses.createandimages.createspend credits and produce something new, so they aredestructiveand need approval.web.searchalso spends credits per search, but it only returns data, so it is aread. Checkbalance.getfor what is left. - A 402 means the credits ran out. Waiting does not help, so the plugin never retries a 402. Errors are core’s
ApiErrorwith the request body removed;textCortexErrorDetails(error)reads the provider’s message, code and per-field details. - The models route is the place to start.
models.listreturns the IDschat.completionsandresponses.createaccept. Use the base ID rather than a deprecated-thinkingvariant; onchat.completions, setreasoning_effortinstead (responses.createdoes not take it). - Two request shapes.
chat.completionstakes an OpenAI-stylemessagesarray.responses.createtakes a singleinputstring with optionalinstructions, and stores nothing: the plugin pinsstore: falseand rejectsstore: true. - Text is the supported content.
chat.completionssends plain-text messages. Image inputs, tool calls and streaming are not modelled, and the request schemas are strict, so an unsupported field such astoolsorstreamis rejected before anything is sent or billed. - Errors come in three shapes. The chat route answers the OpenAI
{ error: { message, type } }envelope, TextCortex’s own routes answer{ message, status }or{ detail }, and a validation failure puts an array indetail. All three are parsed, and a validation array keeps each field’s location. - No retried paid calls. The plugin replays a 5xx only on a GET. A repeated completion can produce and bill a second answer, and TextCortex promises no idempotency key.
- 7 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
Store the TextCortex API key before the first call: More: API Key
pnpm corsair setup --plugin=textcortex --tenant=acme api_key=<your-key> (leave out --tenant without multiTenancy), or pass it as key in the plugin options. With Hub, each tenant enters their own key on the connect page. See API key auth.4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
List the available modelsWhat’s next
API reference
Every
textcortex.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.