FlowModels

Use the OpenAI library for Python and Node.js with FlowModels

Published on 11. November 2026

FlowModels speaks OpenAI's format. That means you can keep using the official OpenAI library for Python or Node.js and only need to swap two things: the base URL and the key. Here's what that looks like, how to send your own additional fields, and where FlowModels deliberately behaves differently from OpenAI.

What you need

  • a key with the Use AI permission from FlowModels › API keys
  • available credit, see Add credit and top up automatically
  • a model identifier from your model list, for example groq/openai/gpt-oss-120b

Store the key as an environment variable, for example FLOWMODELS_API_KEY. It belongs in your backend, never in code that runs in the browser or in an app on the device.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FLOWMODELS_API_KEY"],
    base_url="https://api.flowmodels.one/v1",
)

result = client.chat.completions.create(
    model="groq/openai/gpt-oss-120b",
    messages=[{"role": "user", "content": "Name three benefits of clear project planning."}],
    max_tokens=512,
)

print(result.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FLOWMODELS_API_KEY,
  baseURL: "https://api.flowmodels.one/v1",
});

const result = await client.chat.completions.create({
  model: "groq/openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Name three benefits of clear project planning." }],
  max_tokens: 512,
});

console.log(result.choices[0].message.content);

client.responses.create(...) with result.output_text and client.embeddings.create(...) work the same way. Always specify the full model identifier as provider/model, as shown under Models or in GET /models.

Send FlowModels additional fields

Some fields only exist with us, for example external_identifier for the Brain, conversation, web_search, search_domain_filter or context_compression. The Python library doesn't know these fields as parameters and fails with a TypeError if you pass them directly. So pass them via extra_body:

result = client.chat.completions.create(
    model="groq/openai/gpt-oss-120b",
    messages=[{"role": "user", "content": "What did we last discuss?"}],
    extra_body={"external_identifier": "customer-1042"},
)

In Node.js, simply include the fields in the object. If TypeScript complains about unknown fields, casting the request object helps.

Responses with the Brain also contain the conversation field. The library passes unknown fields through, and in Python you can read them via result.model_dump()["conversation"], for example.

Where FlowModels behaves differently

  • Without max_tokens, the model's maximum applies. A value above this maximum is rejected with 400 invalid_field_value instead of being reduced.
  • Unsupported fields such as n, logprobs, top_logprobs or audio are rejected by the API with 400 unsupported_field. Fields the chosen model doesn't evaluate, such as temperature on some models, come back with 400 unsupported_for_model.
  • Web search is off unless you turn it on with web_search, see Turn on web search, limit it to domains and read the sources.
  • A history that's too long isn't silently shortened, it's rejected with 400 context_length_exceeded, see History too long: context_length_exceeded and history compaction.
  • A dropped connection doesn't continue anything. If you start again, the request is billed again.
  • Costs are shown in every response in usage.cost in euros.

If something goes wrong

  • 401 invalid_token_source: The key must be in the Authorization: Bearer header. The libraries do this automatically, but your own HTTP calls sometimes don't.
  • 404 model_not_found: The identifier is incomplete or not enabled. Check it under Models.
  • 403 insufficient_key_scope: You're using a key with Manage keys or a key from your FlowSuite profile, see FlowAI, FlowModels and subscription keys.

Understanding FlowModels error messages explains all other codes.

Was this article helpful?

Back to Getting started & API keys