Docs · Apps · SDK

OpenAI SDKs

Python, Node.js and any other OpenAI SDK: change two settings.

All apps
WhereYour code

You’ll need an API key. Create one in Dashboard → API keys and give it a monthly limit if the app is shared.

  1. 01

    Python

    Pass base_url and api_key when you create the client.

    Python
    import os
    from openai import OpenAI
    
    client = OpenAI(base_url="https://api.tokenhaven.ai/v1", api_key=os.environ["TOKENHAVEN_API_KEY"])
    reply = client.chat.completions.create(
        model="anthropic/claude-sonnet-4.5",
        messages=[{"role": "user", "content": "Hello"}],
    )
  2. 02

    Node.js

    Pass baseURL and apiKey.

    Node.js
    import OpenAI from "openai";
    
    const client = new OpenAI({ baseURL: "https://api.tokenhaven.ai/v1", apiKey: process.env.TOKENHAVEN_API_KEY });
    const reply = await client.chat.completions.create({
      model: "anthropic/claude-sonnet-4.5",
      messages: [{ role: "user", content: "Hello" }],
    });
  3. 03

    Environment variables

    Many tools built on the OpenAI SDK read these two variables, so you can switch without changing code.

    Terminal
    export OPENAI_BASE_URL=https://api.tokenhaven.ai/v1
    export OPENAI_API_KEY=sk-th-v1-…

OpenAI SDKs’s own docs · Model ids are on the models page.