---
title: "OpenAI SDK to BroadNet migration: code converter and checks"
description: "Paste Python, Node or cURL code that uses the OpenAI SDK and get it pointed at BroadNet Inference, with a diff and a list of what to verify. Runs in your browser."
url: https://broadrouter.com/tools/openai-to-broadnet-migration/
lang: en
updated: 2026-11-16
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# OpenAI to BroadNet migration helper

Updated 2026-11-16

**In short:** Moving OpenAI SDK code to BroadNet Inference takes three edits: base URL https://inference.broadnet.ai/v1, a BroadNet key read from an environment variable, and a BroadNet model ID. Then check what differs: tools and structured output are documented only for GLM 5.3 and Qwen3.8 27B, and there are no embeddings or Responses API. Paste code for the edits and the checks.

Free, no sign-up, runs in your browser: nothing you type is sent anywhere.

Code and targetLanguageDetectPythonNode.js / TypeScriptcURLChat modelDeepSeek V4.1 FlashGLM 5.3Qwen3.8 27BBroadNet Gemma 4 VL 26BTranscription modelBroadNet Transcribe ArabicBroadNet TranscribeKey environment variableYour OpenAI codeConverted in your browser. Nothing is uploaded. Load an example:  ·  · 

**Diff**

**Converted code**

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-openai-to-broadnet-migration&utm_content=tool) · [BroadNet API reference](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-openai-to-broadnet-migration&utm_content=tool-docs) ·

Accounts and keys are managed on inference.broadnet.ai. BroadRouter is BroadNet's own site.

A pattern-based helper, not a compiler: it edits common SDK patterns and flags the rest. Review the diff, run your tests and send one real request before you switch traffic. Capabilities are those in BroadNet's API reference, checked 2026-11-15.

[Report a wrong price or number](mailto:info@broadnet.ai?subject=Wrong%20price%20or%20number%20on%20OpenAI%20to%20BroadNet%20migration%20helper&body=Page%3A%20https%3A%2F%2Fbroadrouter.com%2Ftools%2Fopenai-to-broadnet-migration%2F%0A%0AWhat%20looks%20wrong%20(model%2C%20figure%20shown%2C%20correct%20figure%20and%20a%20source%20link%20if%20you%20have%20one)%3A%0A) (email to info@broadnet.ai, with this page's link and your inputs filled in).

## How it works

1.  Paste Python, Node.js or cURL code that calls the OpenAI API. The language is detected; you can also pick it.
2.  Choose the BroadNet chat model and, for transcription code, the speech-to-text model. Set the environment variable name for the key.
3.  Read the diff: base URL, key from the environment, model IDs, and language=ar when you transcribe Arabic.
4.  Work through the findings: anything not supported on BroadNet, then the checks (streaming, tools, structured output, max\_tokens, limits). Copy the converted code and test one real request.

## What changes when you move from OpenAI to BroadNet?

Three settings, then a check of the features your code uses:

1.  **Endpoint:** `https://inference.broadnet.ai/v1`.
2.  **Key:** a BroadNet inference key, read from an environment variable and sent as `Authorization: Bearer`.
3.  **Model ID:** one of `broadnet/deepseek-v4.1-flash`, `broadnet/glm-5.3`, `broadnet/qwen3.8-27b`, `broadnet/gemma-4-26b-a4b`, `broadnet/cohere-transcribe-arabic`, `broadnet/cohere-transcribe`.

```
from openai import OpenAI
import os

client = OpenAI(
    base_url="https://inference.broadnet.ai/v1",
    api_key=os.environ["BROADNET_API_KEY"],
)
```

## Checklist after the edit

| Feature | On BroadNet (per its API reference) | What to check |
| --- | --- | --- |
| Streaming | Documented for chat completions | Read until `data: [DONE]`; treat an early end as incomplete; verify per model |
| Tool calling | GLM 5.3 and Qwen3.8 27B | Tool schemas, `tool_choice`, parallel calls |
| Structured output | GLM 5.3 and Qwen3.8 27B | Validate returned JSON against your schema |
| Reasoning | DeepSeek V4.1 Flash, GLM 5.3, Qwen3.8 27B | `max_tokens` of 1,000 or more, or `reasoning_effort` low |
| Image input | DeepSeek V4.1 Flash, Qwen3.8 27B, BroadNet Gemma 4 VL 26B | Data URL in the content list; billed as input tokens on pay-as-you-go |
| Transcription | WAV or MP3, up to 26,214,400 bytes | Always send `language`; convert .ogg and .m4a first |
| Limits | 30 requests a minute, 4 in flight per pay-as-you-go key | Client concurrency, backoff on 429 |
| Responses API, embeddings, images, TTS, batch | Not in the API reference | Keep another provider for these, or rewrite |

The full reasoning behind each item is in the [migration checklist](https://broadrouter.com/blog/openai-compatible-api-migration-checklist/). For errors and retries see [error codes and when to retry](https://broadrouter.com/guides/errors-and-retries/).

## Questions

### Is BroadNet Inference a drop-in replacement for the OpenAI API?

It uses the same chat completions and audio transcriptions request shapes, so the OpenAI SDKs work with a different base URL, key and model ID. It is not identical: BroadNet's docs list no batch, files or embeddings endpoint, document tools and structured output only on GLM 5.3 and Qwen3.8 27B, and set their own limits. Expect to check a few parameters, not to change nothing.

### What base URL do I use?

`https://inference.broadnet.ai/v1`. In Python pass `base_url` to `OpenAI()`; in Node pass `baseURL` to `new OpenAI()`; with cURL replace `https://api.openai.com/v1`.

### Which OpenAI endpoints are not available?

BroadNet's API reference documents POST /v1/chat/completions and POST /v1/audio/transcriptions. The Responses API, embeddings, image generation, text to speech, assistants, batches, files, fine-tuning and realtime are not in it, and the tool flags each one. Keep a separate client for anything you still need from another provider.

### Does tool calling work after migrating?

BroadNet documents tool calling and structured output for GLM 5.3 and Qwen3.8 27B. On other models, remove tools or switch model. Test your schemas: support for every JSON Schema keyword can differ between providers.

### Why is my reply empty after switching models?

DeepSeek V4.1 Flash, GLM 5.3 and Qwen3.8 27B reason before answering, and the reasoning counts toward max\_tokens. A small limit that worked on a non-reasoning model can leave no room for the answer. Allow 1,000 tokens or more, or set reasoning\_effort to low. [max\_tokens calculator](https://broadrouter.com/tools/reasoning-token-budget/).

### Is my code sent anywhere?

No. The conversion runs in your browser with string rules; nothing is uploaded, logged or stored. Do not paste real keys anyway: the tool replaces hard-coded keys with an environment variable, and a key that has been in source code should be revoked.

## Go deeper

-   [OpenAI-compatible API migration checklist](https://broadrouter.com/blog/openai-compatible-api-migration-checklist/)
-   [OpenAI Python SDK with BroadNet](https://broadrouter.com/guides/openai-python-sdk/)
-   [OpenAI Node SDK with BroadNet](https://broadrouter.com/guides/openai-node-sdk/)
-   [Developer quickstart](https://broadrouter.com/developers/)
-   [API request builder](https://broadrouter.com/tools/api-request-builder/)

## More free tools

-   [**LLM API cost calculator**Price a workload on every model at once, with cache hits, reasoning and a flat-plan check.](https://broadrouter.com/tools/llm-api-cost-calculator/)
-   [**Speech-to-text cost calculator**Hours, calls or voice notes to a monthly transcription bill, against your current provider.](https://broadrouter.com/tools/speech-to-text-cost-calculator/)
-   [**LLM token counter**Exact token counts with each model's real tokenizer, with a token view and cost.](https://broadrouter.com/tools/token-counter/)
-   [**Arabic token counter**Arabic vs English token counts per tokenizer: the "Arabic tax" in tokens and money.](https://broadrouter.com/tools/arabic-token-counter/)
-   [**Tokens to words converter**Tokens ↔ words ↔ characters ↔ pages, by language and content type.](https://broadrouter.com/tools/tokens-to-words/)
-   [**Context window calculator**Will it fit? Window used per model, room left for output, cost to send.](https://broadrouter.com/tools/context-window-calculator/)
-   [**Flat-rate vs per-token LLM cost calculator**Break-even between an unlimited plan and paying per token, per agent.](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/)
-   [**Prompt caching savings calculator**Bill with and without caching, by prefix share and hit rate.](https://broadrouter.com/tools/prompt-caching-calculator/)
-   [**Image token calculator**Tokens and cost per image under each model's documented rule. Drop an image; nothing is uploaded.](https://broadrouter.com/tools/image-token-calculator/)
-   [**Self-hosting vs API cost calculator**GPU rental against your current API and BroadNet per-token and flat-plan prices: cost per 1M tokens and break-even volume.](https://broadrouter.com/tools/self-hosting-vs-api-calculator/)
-   [**Embedding cost calculator**Index, update and query costs for a corpus at OpenAI, Google, Voyage, Mistral and Jina list prices.](https://broadrouter.com/tools/embedding-cost-calculator/)
-   [**LLM rate limit and concurrency calculator**Which limit binds first: RPM, TPM or concurrency, with Little's law.](https://broadrouter.com/tools/llm-rate-limit-calculator/)
-   [**JSON schema generator for LLM structured output**Sample JSON to strict schema, Pydantic, Zod and a ready request.](https://broadrouter.com/tools/json-schema-generator/)
-   [**OpenAI-compatible API request builder**One request, copied as curl, Python, Node or the OpenAI SDKs.](https://broadrouter.com/tools/api-request-builder/)
-   [**Audio file splitter for speech-to-text limits**Chunk count, overlap and copy-ready ffmpeg commands to fit a transcription file-size limit.](https://broadrouter.com/tools/audio-splitter-ffmpeg/)
-   [**Agent run cost estimator**Context growth per step, total tokens and cost of one agent run, with a DeepSeek session comparison.](https://broadrouter.com/tools/agent-run-cost-estimator/)
-   [**Arabic text normalizer**Tashkeel, tatweel, alef, ya, ta marbuta, digits and invisible characters, with a matching Python function.](https://broadrouter.com/tools/arabic-text-normalizer/)
-   [**RAG chunking calculator**Chunks, embedding tokens, input per query, context check and monthly LLM cost for a RAG pipeline.](https://broadrouter.com/tools/rag-chunking-calculator/)
-   [**max\_tokens calculator for reasoning models**Answer length + reasoning budget + margin = a max\_tokens that does not cut the answer off.](https://broadrouter.com/tools/reasoning-token-budget/)
-   [**LLM batch job planner**Run time, binding limit, cost per model and the flat sessions needed to finish a big job by a deadline.](https://broadrouter.com/tools/llm-batch-job-planner/)
-   [**LLM JSON output validator**Parse errors by line and column, safe repairs, cut-off detection and JSON Schema checks for model output.](https://broadrouter.com/tools/llm-json-output-validator/)
-   [**Prompt token diff**Two prompt versions side by side: changed lines, exact token delta and the monthly cost difference.](https://broadrouter.com/tools/prompt-token-diff/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-openai-to-broadnet-migration&utm_content=page-cta) ·

**Sources**

-   [BroadNet Inference machine-readable prices (pricing.json)](https://inference.broadnet.ai/pricing.json?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-openai-to-broadnet-migration&utm_content=sources)
-   [BroadNet Inference API reference: base URL, model IDs, capabilities, limits and errors (checked 2026-11-15)](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=tools-openai-to-broadnet-migration&utm_content=sources)
-   [OpenAI Python SDK (base\_url and api\_key client options)](https://github.com/openai/openai-python)
-   [OpenAI Node SDK (baseURL and apiKey client options)](https://github.com/openai/openai-node)
