DEV Community

Saathwik
Saathwik

Posted on

Using an OpenAI-compatible API with 262K context and tool calling

If you already use the OpenAI SDK, switching to another provider is mostly a two line change. Here is a minimal setup for an OpenAI-compatible endpoint with a 262K token context window and tool calling.

Setup

from openai import OpenAI

client = OpenAI(
    base_url="https://api.saanora.com/v1",
    api_key="YOUR_API_KEY",
)

resp = client.chat.completions.create(
    model="mark-1x-27b",
    messages=[{"role": "user", "content": "Summarize this long report in five bullets."}],
)
print(resp.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Tool calling

Tools use the standard tools parameter, so existing function definitions keep working:

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

resp = client.chat.completions.create(
    model="mark-1x-27b",
    messages=[{"role": "user", "content": "Weather in Paris?"}],
    tools=tools,
)
print(resp.choices[0].message.tool_calls)
Enter fullscreen mode Exit fullscreen mode

Why the long context helps

With 262K tokens you can pass whole documents or long agent histories without chunking first, which keeps your pipeline simpler.

Pricing is $0.10 per 1M input tokens and $0.60 per 1M output tokens, and new accounts get free credit to try it. The model is called Mark 1x-27B, and you can also chat with it free at https://saanora.com. Happy to hear what breaks or what you would want added.

Top comments (0)