For the complete documentation index, see llms.txt. This page is also available as Markdown.

OpenAI SDK

Use the official OpenAI SDKs with Cortecs

The official OpenAI Python and JavaScript SDKs can call Cortecs through its compatible APIs. Prefer the Responses API for new agent workflows and use Chat Completions when a library or model requires it.

Create a Cortecs API key by following the Quickstart, then choose a model with the required capabilities from the Models API.

Responses API

Install the SDK:

pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.cortecs.ai/v1",
    api_key=os.environ["CORTECS_API_KEY"],
)

response = client.responses.create(
    model=os.environ["CORTECS_MODEL"],
    instructions="Answer concisely.",
    input="Name three uses for semantic search.",
    extra_body={"preference": "balanced"},
)

print(response.output_text)

Install the SDK:

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.cortecs.ai/v1",
  apiKey: process.env.CORTECS_API_KEY,
});

const response = await client.responses.create({
  model: process.env.CORTECS_MODEL,
  instructions: "Answer concisely.",
  input: "Name three uses for semantic search.",
});

console.log(response.output_text);

The JavaScript SDK does not expose Cortecs routing fields as typed parameters. Set project defaults in Cortecs or use a client that supports custom request body fields when per-request routing is required.

Chat Completions fallback

Use this shape when a dependency only supports Chat Completions:

The fallback endpoint is https://api.cortecs.ai/v1/chat/completions. See API Compatibility before translating more advanced Responses requests.

For request-shape differences, see OpenAI's Responses migration guide. Cortecs compatibility is limited to the fields in the Cortecs API reference.

Last updated