Home › Docs › SDKs and integrations

Get started

SDKs and integrations

Anything that lets you set an OpenAI-compatible base URL works with apicuts. Here are copy-and-paste examples for the most common stacks.

Every example reads your endpoint and key from the APICUTS_BASE_URL and APICUTS_API_KEY environment variables. See the quickstart to set them.

OpenAI Python SDK

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ["APICUTS_BASE_URL"],  # the only line you change
    api_key=os.environ["APICUTS_API_KEY"],
)

response = client.chat.completions.create(
    model="your-model",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

OpenAI TypeScript SDK

TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: process.env.APICUTS_BASE_URL, // the only line you change
  apiKey: process.env.APICUTS_API_KEY,
});

const response = await client.chat.completions.create({
  model: "your-model",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);

LangChain

Python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="your-model",
    base_url=os.environ["APICUTS_BASE_URL"],
    api_key=os.environ["APICUTS_API_KEY"],
)
print(llm.invoke("Hello").content)

LlamaIndex

Python
import os
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="your-model",
    api_base=os.environ["APICUTS_BASE_URL"],
    api_key=os.environ["APICUTS_API_KEY"],
    is_chat_model=True,
)
print(llm.complete("Hello"))

Vercel AI SDK

TypeScript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const apicuts = createOpenAICompatible({
  name: "apicuts",
  baseURL: process.env.APICUTS_BASE_URL!,
  apiKey: process.env.APICUTS_API_KEY,
});

const { text } = await generateText({
  model: apicuts("your-model"),
  prompt: "Hello",
});

cURL

Shell
curl "$APICUTS_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $APICUTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "your-model", "messages": [{"role": "user", "content": "Hello"}]}'

Any OpenAI-compatible tool

Agent frameworks, coding assistants and internal tools that let you choose a custom OpenAI base URL and API key work the same way: paste your apicuts endpoint and key into those two fields.

Behind LiteLLM or Portkey

Already run a gateway? Keep it. Add apicuts as an OpenAI-compatible upstream, and your existing routing and logging stay in place while apicuts handles the savings.

Want us to find your 20%?

Book a free 15-minute API cost teardown. Bring last month's provider usage and we'll show you your biggest waste and the first fix we'd ship.

Get a Free 15-Minute API Cost Teardown