---
title: "CrewAI custom OpenAI-compatible base_url setup | BroadRouter"
description: "Point CrewAI agents at BroadNet Inference with LLM(custom_openai=True, base_url=...), then pick models for tools, long context and the flat-rate plan."
url: https://broadrouter.com/guides/crewai-custom-openai-endpoint/
lang: en
updated: 2026-11-16
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Use CrewAI with BroadNet Inference as a custom OpenAI endpoint

Updated 2026-11-16

Create the model with crewai's LLM class, passing model set to a BroadNet ID such as broadnet/glm-5.3, custom\_openai=True, base\_url set to https://inference.broadnet.ai/v1 and api\_key set to your BroadNet key. Then give that LLM to each Agent. CrewAI uses its native OpenAI client and chat completions, so no LiteLLM install is needed.

CrewAI is a Python framework for teams of agents. Its docs show a **custom OpenAI-compatible endpoint** pattern: an `LLM` with `custom_openai=True` and a `base_url`. BroadNet Inference serves standard chat completions at `https://inference.broadnet.ai/v1`, so it plugs in there. BroadRouter is BroadNet’s own site; this follows CrewAI’s docs and source as of version 1.15.41.

## Install

```bash
pip install crewai
export BROADNET_API_KEY='your-broadnet-key'
```

## Connect

```python
import os
from crewai import LLM, Agent

llm = LLM(
    model="broadnet/glm-5.3",
    custom_openai=True,
    base_url="https://inference.broadnet.ai/v1",
    api_key=os.environ["BROADNET_API_KEY"],
    max_tokens=4000,  # reasoning counts toward this limit
)

# Quick test: one call straight to the model
print(llm.call("Say hello in five words."))

analyst = Agent(
    role="Analyst",
    goal="Summarize incidents",
    backstory="You write short incident summaries.",
    llm=llm,
)
print(analyst.kickoff("Summarize: the API returned 503 for four minutes after a deploy."))
```

If `llm.call` prints an answer, the key, URL and model ID are right.

## How CrewAI routes the request

CrewAI’s source sets an order: `custom_openai=True` comes first and forces the native OpenAI provider, overriding anything the model name suggests. It also raises an error unless a custom endpoint is set through `base_url`, `api_base`, `OPENAI_BASE_URL` or `OPENAI_API_BASE`. The model string is sent as written, so `broadnet/glm-5.3` reaches BroadNet unchanged.

Without `custom_openai`, a name such as `broadnet/glm-5.3` would be read as provider `broadnet`, which CrewAI doesn’t know, and would fall back to LiteLLM. The documented alternative is `model="openai/broadnet/glm-5.3"` with a `base_url`: CrewAI strips the `openai/` prefix and sends the rest.

Two more things from CrewAI’s code and docs:

-   **Token limit field.** When you pass `max_tokens`, the native client sends `max_tokens` on chat completions, the field BroadNet’s API reference describes. If you pass `max_completion_tokens`, that is sent instead.
-   **Stay on chat completions.** CrewAI’s docs show `api="responses"` to switch to the Responses API. Don’t set it; BroadNet doesn’t list that API.

## Which model for which agent

| Agent | Model | Why |
| --- | --- | --- |
| Agents with tools | `broadnet/glm-5.3` | BroadNet lists tools and structured output; 1M context |
| Image or Arabic input, with tools | `broadnet/qwen3.8-27b` | Tools plus images; 262K context |
| Long reading tasks, flat-rate plan | `broadnet/deepseek-v4.1-flash` | Unlimited plans; tools not listed by BroadNet |

A crew can mix them: give each `Agent` its own `LLM`.

## Troubleshooting

-   **401.** The key is wrong, expired or out of allowance. If you left out `api_key`, CrewAI read `OPENAI_API_KEY`, which may hold an OpenAI key.
-   **“custom\_openai=True requires base\_url”.** Pass `base_url`, or set `OPENAI_BASE_URL`.
-   **Model not found.** Check the ID matches BroadNet’s exactly. Paid models need a top-up; the $5 credit covers only `broadnet/gemma-4-26b-a4b` and the two Transcribe models.
-   **`EmptyLLMResponseError`.** CrewAI retries an empty answer once, then raises this. Raise `max_tokens`. [Why answers come back empty](https://broadrouter.com/guides/reasoning-tokens-empty-response/).
-   **429 with several agents.** A pay-as-you-go key allows 30 requests a minute and 4 in flight, and a plan session runs one request at a time. See [errors and retries](https://broadrouter.com/guides/errors-and-retries/).

## Terms in this guide

[Tool calling](https://broadrouter.com/glossary/tool-calling/)

Tool calling, also called function calling, is an LLM API feature in which the model returns a structured request to run a function the developer has defined, with JSON arguments. The application runs the function and sends the result back; the model never runs code itself.

[Chat Completions API](https://broadrouter.com/glossary/chat-completions-api/)

The Chat Completions API is OpenAI's HTTP endpoint, POST /v1/chat/completions, that takes a model name and a list of role-tagged messages and returns the model's next message. Its request and response shape became the common format that OpenAI-compatible providers and SDKs reuse.

[Pay-as-you-go](https://broadrouter.com/glossary/pay-as-you-go/)

Pay-as-you-go is a pricing model in which you pay only for what you use, metered per unit such as tokens, requests or audio minutes, with no subscription or minimum commitment. Most LLM APIs bill this way, from a prepaid balance or a periodic invoice.

[Concurrency](https://broadrouter.com/glossary/concurrency/)

Concurrency is the number of requests a client has in flight at the same time. LLM APIs often cap it per key or plan, separately from requests per minute, because each open request holds GPU capacity until its response has finished.

[Context window](https://broadrouter.com/glossary/context-window/)

A context window is the maximum number of tokens a language model can work with in a single request. It covers the prompt, conversation history, tool definitions, images and the generated output, including any reasoning tokens. Anything that does not fit must be cut, summarised or split across several requests.

[Prepaid credit](https://broadrouter.com/glossary/prepaid-credit/)

Prepaid credit is money added to an API account before use. Each request deducts its cost from the balance, and when the balance runs out, metered requests stop until you top up. It caps spend at what you have paid in.

[Rate limit](https://broadrouter.com/glossary/rate-limit/)

A rate limit is a cap an API places on how much a client can use it in a time window, such as requests per minute or tokens per minute. Requests over the limit are refused, usually with HTTP 429 Too Many Requests, until usage falls back under it.

[Structured output](https://broadrouter.com/glossary/structured-output/)

Structured output is an LLM API feature that constrains a model's reply to a format the developer specifies, usually a JSON Schema, so code can parse it reliably. It is stricter than JSON mode, which guarantees valid JSON but not a particular shape.

## Questions

### What does custom\_openai=True do in CrewAI?

CrewAI's source says it forces the native OpenAI provider whatever the model name looks like, and it requires base\_url, api\_base, OPENAI\_BASE\_URL or OPENAI\_API\_BASE. The model string is sent as written, so broadnet/glm-5.3 reaches BroadNet unchanged.

### Can I write model="openai/broadnet/glm-5.3" instead?

Yes. With a custom base\_url, CrewAI routes an openai/ prefix to its native OpenAI client and strips the prefix, so BroadNet receives broadnet/glm-5.3. custom\_openai=True is the clearer form.

### Why does my crew fail with EmptyLLMResponseError?

CrewAI retries an empty answer, one with no content and no tool calls, once, and raises this error if the retry is empty too. On BroadNet's reasoning models that usually means the reasoning used the output budget. Raise max\_tokens.

### Which BroadNet model should CrewAI agents use?

GLM 5.3 for agents with tools, since BroadNet lists tools and structured output for it. Qwen3.8 27B also has tools and takes images.

## Related guides

-   [Use Pydantic AI with BroadNet Inference (OpenAICompatibleProvider)](https://broadrouter.com/guides/pydantic-ai-openai-compatible/)
-   [Use the OpenAI Python SDK with BroadNet Inference](https://broadrouter.com/guides/openai-python-sdk/)
-   [Why a reasoning model returns an empty answer](https://broadrouter.com/guides/reasoning-tokens-empty-response/)
-   [BroadNet Inference error codes and when to retry](https://broadrouter.com/guides/errors-and-retries/)
-   [All tools that work with BroadNet Inference](https://broadrouter.com/integrations/): SDKs, coding agents, chat UIs and automation tools, with exact settings for each

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=guides-crewai-custom-openai-endpoint&utm_content=page-cta) ·

**Sources**

-   [CrewAI docs, LLMs (OpenAI, custom OpenAI-compatible endpoint) (checked 2026-11-15)](https://docs.crewai.com/en/concepts/llms)
-   [CrewAI source, LLM routing for custom\_openai (llm.py) (checked 2026-11-15)](https://github.com/crewAIInc/crewAI/blob/main/lib/crewai/src/crewai/llm.py)
-   [PyPI, crewai 1.15.41, Python 3.10 to 3.13 (checked 2026-11-15)](https://pypi.org/project/crewai/)
-   [BroadNet Inference API reference (checked 2026-11-15)](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=guides-crewai-custom-openai-endpoint&utm_content=sources)
