ai newsDi., 1. Dez.

Anleitung: Mark 1x-27B mit dem OpenAI Python SDK aufrufen

Saanora-Gründer Saathwik erklärt, wie sich das Sprachmodell Mark 1x-27B über das OpenAI Python SDK anbinden lässt. Das Modell lässt sich ohne Registrierung im Browser testen.

dev.toFreitag 21:57 · 27.11.DE3 Min. Lesezeit
Bild: dev.to

Ich bin Saathwik, Gründer von Saanora, und ich entwickle Mark. Dieser Beitrag ist eine kurze Anleitung zur Einrichtung von Mark 1x-27B, unserem neuesten Modell, mit dem OpenAI Python SDK, das Sie wahrscheinlich bereits installiert haben.

Sie können das Modell ohne Registrierung direkt im Browser unter saanora.com ausprobieren. Der Rest dieses Artikels handelt davon, wie man es aus dem Code heraus aufruft.

Die API ist OpenAI-kompatibel. Richten Sie den Client auf https://api.saanora.com/v1 und setzen Sie das Modell auf mark-1x-27b. Chat completions, Streaming, Tool Calling und Bildeingaben verwenden alle das übliche Anfrageformat. Der Kontext umfasst 262K. Sie können reasoning_effort auf low, medium oder high setzen. Medium ist der Standardwert, und so wurden auch die unten genannten Ergebnisse erzielt.

Der Preis beträgt 0,10 Dollar pro 1M Eingabe-Tokens und 0,60 Dollar pro 1M Ausgabe-Tokens, mit Startguthaben kostenlos. Erstellen Sie einen Schlüssel in der API-Konsole und hinterlegen Sie ihn in SAANORA_API_KEY.

Ergebnisse bei mittlerem Aufwand: GPQA 84,7, auf Augenhöhe mit den besten offenen Modellen seiner Größe; AIME25 86,7; HMMT Feb26 73,5. Der ausführliche Bericht steht in unserem Blog.

# mark.py: pip install openai, dann python mark.py import os from openai import OpenAI client = OpenAI ( base_url = "https://api.saanora.com/v1", api_key = os. environ [ "SAANORA_API_KEY" ], ) r = client. chat. completions. create ( model = "mark-1x-27b", messages = [ { "role": "user", "content": "How many prime numbers are there below 100?" } ], ) print ( r. choices [ 0 ]. message. content ) Enter fullscreen mode Exit fullscreen mode Die Antwort steht in choices.message.content.

Die Gedanken des Modells werden in einem separaten reasoning-Feld zurückgegeben, nicht in die Antwort eingemischt. Ein höherer Aufwand kostet mehr Zeit und mehr Ausgabe-Tokens, daher verwende ich high für Beweise, tricky Bugs und lange Pläne, und lasse den Standardwert für alltägliche Fragen unverändert.

r = client. chat. completions. create ( model = "mark-1x-27b", messages = [ { "role": "user", "content": "Prove that the square root of 2 is irrational." } ], reasoning_effort = "high", # low | medium (default) | high ) print ( r. choices [ 0 ]. message. reasoning ) print ( r. choices [ 0 ]. message. content ) Enter fullscreen mode Exit fullscreen mode max_tokens umfasst das Reasoning und liegt standardmäßig bei 32.768. Wenn ein schwieriges Problem möglicherweise lange nachdenkt, erhöhen Sie dieses Budget und streamen Sie die Antwort.

Das Modell skaliert herunter, wenn niemand es nutzt. Nach einer ruhigen Phase kann die erste Anfrage einen 503 zurückgeben, während es hochfährt, was einige Minuten dauern kann. Diese Anfrage wird nicht berechnet. Der eingebaute Retry-Mechanismus des OpenAI SDK reicht meist nicht aus, deshalb probiere ich es so lange erneut, bis es antwortet:

import time import openai for attempt in range ( 10 ): try: r = client. chat. completions. create ( model = "mark-1x-27b", messages = messages, stream = True, ) break except openai. APIStatusError as e: if e. status_code!= 503: raise time. sleep ( int ( e. response. headers. get ( "retry-after", "30" ) ) ) Enter fullscreen mode Exit fullscreen mode Was ich zurückmelden möchte: Wenn Sie dies in einer Editor-Erweiterung, einem Coding-Agent oder einem einfachen Skript ausprobieren, erzählen Sie mir, was funktioniert hat und was nicht. Ich bin in den Kommentaren erreichbar.

Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.

Original (Englisch) anzeigen

I'm Saathwik, founder of Saanora, and I'm building Mark. This post is a short setup guide for Mark 1x-27B, our latest model, using the OpenAI Python SDK you probably already have.

You can try the model in the browser with no signup at saanora.com. The rest of this article is about calling it from code.

The API is OpenAI-compatible. Point the client at https://api.saanora.com/v1 and set the model to mark-1x-27b. Chat completions, streaming, tool calling, and image input all use the usual request shape. Context is 262K. You can set reasoning_effort to low, medium, or high. Medium is the default, and it is also how we ran the scores below.

Price is $0.10 per 1M input tokens and $0.60 per 1M output tokens, with free credit to start. Create a key in the API console and put it in SAANORA_API_KEY.

Scores at medium effort: GPQA 84.7, level with the best open models its size; AIME25 86.7; HMMT Feb26 73.5. The longer write-up is on our blog.

# mark.py: pip install openai, then python mark.py import os from openai import OpenAI client = OpenAI ( base_url = "https://api.saanora.com/v1", api_key = os. environ [ "SAANORA_API_KEY" ], ) r = client. chat. completions. create ( model = "mark-1x-27b", messages = [ { "role": "user", "content": "How many prime numbers are there below 100?" } ], ) print ( r. choices [ 0 ]. message. content ) Enter fullscreen mode Exit fullscreen mode The answer is in choices.message.content.

The model's thinking comes back in a separate reasoning field, not mixed into the answer. Higher effort costs more time and more output tokens, so I use high for proofs, tricky bugs, and long plans, and leave the default alone for everyday questions.

r = client. chat. completions. create ( model = "mark-1x-27b", messages = [ { "role": "user", "content": "Prove that the square root of 2 is irrational." } ], reasoning_effort = "high", # low | medium (default) | high ) print ( r. choices [ 0 ]. message. reasoning ) print ( r. choices [ 0 ]. message. content ) Enter fullscreen mode Exit fullscreen mode max_tokens includes the reasoning and defaults to 32,768. If a hard problem may think for a long time, raise that budget and stream the response.

The model scales down when no one is using it. After a quiet period, the first request can return 503 while it starts, which can take a few minutes. That request is not charged. The OpenAI SDK's built-in retry is usually not enough, so I retry until it answers:

import time import openai for attempt in range ( 10 ): try: r = client. chat. completions. create ( model = "mark-1x-27b", messages = messages, stream = True, ) break except openai. APIStatusError as e: if e. status_code!= 503: raise time. sleep ( int ( e. response. headers. get ( "retry-after", "30" ) ) ) Enter fullscreen mode Exit fullscreen mode What I'd like back If you try this in an editor extension, a coding agent, or a plain script, tell me what worked and what broke. I'm around in the comments.

Originaltitel: How to call Mark 1x-27B with the OpenAI Python SDKQuelle: dev.to (dev.to). Original öffnen