Create .env from .env.example or export the variable in your shell.
Check that:
OPENAI_COMPAT_API_KEYis valid for the provider.OPENAI_COMPAT_BASE_URLpoints to the same provider as the key.- Your account has access to the selected model.
Most OpenAI-compatible providers expect:
OPENAI_COMPAT_BASE_URL=https://provider.example/v1The examples append /chat/completions automatically. Do not set the base URL to the full endpoint path.
Possible causes:
- The provider does not support
stream: truefor that model. - The provider buffers chunks until completion.
- The response uses SSE but omits
delta.contentfor some chunks. - The model is producing a tool-call delta instead of text.
Run the non-streaming example first to confirm basic connectivity.
This can be normal. OpenAI-compatible providers do not always implement identical tool/function-call semantics. Check:
- Does the provider document
toolssupport? - Does the selected model support tool calls?
- Does the provider still use legacy
functionsinstead oftools? - Are function arguments emitted as a JSON string or as parsed JSON?
JSON mode is not universal. If your provider rejects response_format, use prompt-based JSON output or choose a model/provider that explicitly supports JSON mode.
TKEN example base URL:
OPENAI_COMPAT_BASE_URL=https://www.tken.shop/v1TKEN help/start link: https://www.tken.shop/?utm_source=github&utm_medium=repo&utm_campaign=openai-compatible-streaming-tool-calls&utm_content=troubleshooting