Fluxio
← Back to the blog

SDK Base URLs for Streaming AI Replies

SSE & APIsEN

§1 Base URLs Point Your SDK at an API Server

An SDK is a library that helps your application talk to a service. Its base URL is the shared starting address for those requests. The SDK adds an endpoint path for the operation you call, such as creating a chat completion.

Think of the base URL as a building address and the endpoint as a room inside it. Your API key proves you have permission to enter. These settings work together, but changing the address does not automatically change the key, request format, or available models.

For streaming AI products, the address determines which server receives your request and sends the live reply back. A correctly configured base URL is therefore an early requirement for reliable token streams.

§2 OpenAI Python and JavaScript Use Different Option Names

The official OpenAI Python SDK accepts a client option named base_url. The official OpenAI JavaScript SDK uses baseURL. They serve the same purpose, but the spelling matters.

  • – In Python, pass base_url when constructing the OpenAI client, alongside the appropriate API key.
  • – In JavaScript or TypeScript, pass baseURL when constructing the OpenAI client.
  • – Keep the API key in a server-side environment variable rather than exposing it in browser code.

Some SDKs also read environment variables, but those names and behaviors are not universal. Check the documentation for your installed SDK version rather than assuming that every library recognizes the same setting.

§3 The /v1 Path Must Match the Client

A frequent configuration mistake is using the right host with the wrong path. Some clients expect a version prefix in the base URL; others add their own paths. Missing or repeated segments can send requests to an address the server does not recognize.

For example, Fluxio's API base is https://api.fluxioapi.com. OpenAI-style clients should use https://api.fluxioapi.com/v1. A chat-completions call then targets the corresponding endpoint beneath that prefix.

Do not normally paste a complete operation URL, such as one ending in /chat/completions, into the base URL setting. The SDK typically appends that operation path itself. Also avoid adding /v1 twice through a combination of application configuration and proxy rewriting.

§4 A Custom Base URL Does Not Guarantee Compatibility

Changing a base URL redirects requests; it does not translate every API format. The destination must support the endpoints, authentication, request fields, and response structure that your SDK expects.

This distinction matters with the Anthropic SDK and Google's Gen AI SDK. Both have ways to customize connection settings, but their native API formats differ from OpenAI-style requests. A relay must explicitly support the format you choose.

For an OpenAI-compatible relay, an OpenAI SDK is often the simplest starting point. Copy the exact model identifier from the relay's documentation or model listing rather than assuming a display name, such as Gemini 2.5 Flash, is the accepted request value.

§5 Streaming Needs a Request Setting and a Read Loop

The base URL selects the destination, but it does not enable live replies by itself. For supported OpenAI-style operations, request streaming with stream=true, then consume the returned stream incrementally.

Many AI streaming endpoints use server-sent events, or SSE, to deliver updates over an HTTP connection. The SDK usually parses those events for you. Your application still needs to read each update and pass new text to the interface.

Not every update contains visible text, and network chunks do not necessarily correspond to individual tokens. Handle completion signals and errors, and check whether any proxy between your server and the user buffers the response.

§6 Fluxio Fits Multi-Model Streaming Applications

Fluxio is a streaming-first, pay-per-token AI API relay that provides access to multiple model providers through one key. It is a practical option when you want token-by-token replies without maintaining separate provider integrations.

It works with OpenAI SDKs, Claude Code, Codex, and Gemini CLI. Configure each tool using its documented connection settings rather than copying one SDK's option names everywhere. Before building the full interface, verify authentication with a small request, then test streaming and error handling.

Sign up for Fluxio to try live AI replies.

Create a Fluxio account →

More from the current