OpenAI-SDKs auf ein Modell mit weniger Ablehnungen umleiten
Sicherheits-Teams stossen mit generellen Modellen oft auf Ablehnungen, etwa bei der Analyse eigener Malware-Samples oder beim Entwurf von Detection Rules. Das Muster funktioniert mit jedem OpenAI-kompatiblen Provider.

Veröffentlicht am 19. Nov • Ursprünglich veröffentlicht auf docs.interodin.com • KI-unterstützt
Hinweis: Ich arbeite an InterOdin, der in diesem Tutorial verwendeten API. Das Muster funktioniert mit jedem OpenAI-kompatiblen Anbieter.
Sicherheitsskripte stoßen bei generalistischen Modellen oft an eine Grenze: Eine Anfrage, eine Malware-Probe aus dem eigenen Vorfall zu erklären oder eine Erkennungsregel zu entwerfen, wird als Ablehnung beantwortet. Wenn Ihr Code bereits das offizielle OpenAI SDK verwendet, können Sie das dahinterliegende Modell über eine Base-URL und einen Schlüssel austauschen. Diese Anleitung verwendet Odin v1 über InterOdin, das sowohl Chat Completions als auch Responses anbietet.
import os from openai import OpenAI client = OpenAI ( base_url = "https://api.interodin.com/v1", api_key = os. environ [ "INTERODIN_API_KEY" ], ) completion = client. chat. completions. create ( model = "odin-v1", messages = [ { "role": "user", "content": "Say hello in Romanian." } ], ) print ( completion. choices [ 0 ]. message. content ) Vollbildmodus öffnen Vollbildmodus beenden TypeScript:
import OpenAI from 'openai' const client = new OpenAI ( { baseURL: 'https://api.interodin.com/v1', apiKey: process. env. INTERODIN_API_KEY, } ) const completion = await client. chat. completions. create ( { model: 'odin-v1', messages: [ { role: 'user', content: 'Say hello in Romanian.' } ], } ) console. log ( completion. choices [ 0 ]?. message. content ) Vollbildmodus öffnen Vollbildmodus beenden Gar keine Codeänderungen? Beide SDKs lesen diese Umgebungsvariablen:
export OPENAI_BASE_URL = "https://api.interodin.com/v1" export OPENAI_API_KEY = "io-sk-your-key" Vollbildmodus öffnen Vollbildmodus beenden Responses API response = client. responses. create ( model = "odin-v1", input = "Say hello in Romanian.", store = False ) print ( response. output_text ) Vollbildmodus öffnen Vollbildmodus beenden Responses ist hier zustandslos: Senden Sie die gesamte Konversation bei jedem Zug in input.
Die SDKs werfen ihre üblichen Exceptions: AuthenticationError für 401, RateLimitError für 429 sowie APIStatusError- und APIError-Unterklassen für den Rest. Lesen Sie das Feld code, um insufficient_credits (402) von anderen Fehlern zu unterscheiden. 429 und 5xx werden automatisch wiederholt.
Die Abrechnung erfolgt über Prepaid-Credits pro Token, ohne Abo, und API-Prompts sowie Completions werden nicht gespeichert. Weniger Ablehnungen bedeutet nicht, dass es keine Regeln gibt: Die Acceptable Use Policy verbietet illegale und schädliche Nutzung, verwenden Sie das Modell also nur für Systeme und Daten, an denen Sie autorisiert sind zu arbeiten.
Die gepflegte Version dieses Leitfadens befindet sich in der Dokumentation: https://docs.interodin.com/en/integrations/openai-sdk
Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.
Original (Englisch) anzeigen
Posted on Nov 19 • Originally published at docs.interodin.com • AI-assisted
Disclosure: I work on InterOdin, the API used in this tutorial. The pattern works for any OpenAI-compatible provider.
Security scripts often hit a wall with general-purpose models: a request to explain a malware sample from your own incident, or to draft a detection rule, comes back as a refusal. If your code already uses the official OpenAI SDK, you can switch the model behind it with a base URL and a key. This walkthrough uses Odin v1 through InterOdin, which serves both Chat Completions and Responses.
import os from openai import OpenAI client = OpenAI ( base_url = "https://api.interodin.com/v1", api_key = os. environ [ "INTERODIN_API_KEY" ], ) completion = client. chat. completions. create ( model = "odin-v1", messages = [ { "role": "user", "content": "Say hello in Romanian." } ], ) print ( completion. choices [ 0 ]. message. content ) Enter fullscreen mode Exit fullscreen mode TypeScript:
import OpenAI from 'openai' const client = new OpenAI ( { baseURL: 'https://api.interodin.com/v1', apiKey: process. env. INTERODIN_API_KEY, } ) const completion = await client. chat. completions. create ( { model: 'odin-v1', messages: [ { role: 'user', content: 'Say hello in Romanian.' } ], } ) console. log ( completion. choices [ 0 ]?. message. content ) Enter fullscreen mode Exit fullscreen mode No code changes at all? Both SDKs read these environment variables:
export OPENAI_BASE_URL = "https://api.interodin.com/v1" export OPENAI_API_KEY = "io-sk-your-key" Enter fullscreen mode Exit fullscreen mode Responses API response = client. responses. create ( model = "odin-v1", input = "Say hello in Romanian.", store = False ) print ( response. output_text ) Enter fullscreen mode Exit fullscreen mode Responses is stateless here: send the full conversation in input on each turn.
The SDKs raise their usual exceptions: AuthenticationError for 401, RateLimitError for 429, and APIStatusError / APIError subclasses for the rest. Read the code field to tell insufficient_credits (402) apart from other errors. 429 and 5xx are retried automatically.
Billing is prepaid credits per token, with no subscription, and API prompts and completions are not stored. Fewer refusals does not mean no rules: the Acceptable Use Policy forbids illegal and harmful uses, so use it on systems and data you are authorised to work on.
The maintained version of this guide lives in the docs: https://docs.interodin.com/en/integrations/openai-sdk