The official OpenAI Node SDK talks to
Hyphen with one changed option. Every framework on the TypeScript pages is
built on this, so it is worth knowing what the layer underneath looks like.
Code
npm install openaiexport HYPHEN_API_KEY="sk-..."
Setup guide: this config comes from the OpenAI Node SDK's official
documentation and has not been run end to end against the gateway.
Corrections to support@hyphen-solution.com.
Minimal
Code
import OpenAI from "openai";const client = new OpenAI({ baseURL: "https://api.hyphen-solution.com/v1", apiKey: process.env.HYPHEN_API_KEY,});const resp = await client.chat.completions.create({ model: "minimax-m3", messages: [{ role: "user", content: "Explain a Bloom filter in three sentences." }], max_tokens: 2000,});console.log(resp.choices[0].message.content);console.log(resp.usage);
Save as app.mjs and run node app.mjs. That is the whole integration.
Streaming
Code
const stream = await client.chat.completions.create({ model: "minimax-m3", messages: [{ role: "user", content: "Count to ten slowly." }], max_tokens: 2000, stream: true,});for await (const chunk of stream) { const delta = chunk.choices[0]?.delta?.content; if (delta) process.stdout.write(delta);}
The ?. chain matters. The final usage chunk can arrive with an empty
choices array.
Full walkthrough of this pattern, including the Anthropic surface, on
Tool calling.
TypeScript types
The SDK ships its own types and they work unchanged. Model IDs are plain
strings, so a Hyphen model name type-checks fine:
Code
import OpenAI from "openai";import type { ChatCompletionMessageParam } from "openai/resources/chat/completions";const client = new OpenAI({ baseURL: "https://api.hyphen-solution.com/v1", apiKey: process.env.HYPHEN_API_KEY,});const messages: ChatCompletionMessageParam[] = [ { role: "system", content: "You are terse." }, { role: "user", content: "Define idempotent." },];const resp = await client.chat.completions.create({ model: "minimax-m3", messages, max_tokens: 2000,});
Options worth setting
Code
const client = new OpenAI({ baseURL: "https://api.hyphen-solution.com/v1", apiKey: process.env.HYPHEN_API_KEY, maxRetries: 0, // handle 429 yourself, see below timeout: 120_000, // reasoning models can take a while on hard prompts});
Turn off maxRetries if you are doing your own 429 handling. Left on, the SDK
silently retries budget 429s that will never succeed, which just adds latency
and hides the real error. See Handling the 429 cap.
The Python equivalent
Identical, with base_url instead of baseURL:
Code
import osfrom openai import OpenAIclient = OpenAI( base_url="https://api.hyphen-solution.com/v1", api_key=os.environ["HYPHEN_API_KEY"],)resp = client.chat.completions.create( model="minimax-m3", messages=[{"role": "user", "content": "Explain a Bloom filter in three sentences."}], max_tokens=2000,)print(resp.choices[0].message.content)
Gotchas
max_tokens must be generous. 2000 for chat, 4000 for tools. The
M-series burn budget on reasoning before emitting anything, and a tight cap
returns an empty string. See
Choosing a model.
response_format does nothing. JSON mode is not supported on the
M-series. Use a tool schema instead, per
Structured JSON output.
No client.embeddings. The catalog has no embedding models.
client.responses works too. Hyphen serves the Responses API at
/v1/responses, which is what Codex CLI uses.
Related
Vercel AI SDK: the framework most TypeScript apps use instead.
Recipes: streaming, tools, agent loops, 429 handling.