Base URL Configuration in Popular AI SDKs
§1 Step 1: Separate the API Base URL From the Request Path
A custom base URL lets an SDK send requests to a different API host. In the OpenAI Python client, resource paths are combined with the configured base URL. Configure the API root rather than pasting a complete operation URL into the client constructor. ([github.com](https://github.com/openai/openai-python/blob/main/docs/architecture/security-model.md?utm_source=openai))
For this walkthrough, use Fluxio’s supplied OpenAI-compatible base: https://api.fluxioapi.com/v1. The service root is https://api.fluxioapi.com, but OpenAI-style clients need the additional /v1. Do not append /chat/completions to the base setting; select that operation through the SDK instead.
Fluxio fits applications that want a streaming-first, pay-per-token relay with one key across multiple model providers. Treat the relay address, relay credential, and selected model identifier as three separate configuration values.
§2 Step 2: Configure the OpenAI Python SDK
Install the official package with pip install openai. Import the client using from openai import OpenAI. The Python SDK accepts the constructor options api_key and base_url, and it also supports the OPENAI_BASE_URL environment variable. ([developers.openai.com](https://developers.openai.com/api/docs/libraries?utm_source=openai))
For explicit configuration, construct OpenAI(api_key=relay_key, base_url=relay_base), where your application loads both variables from its server-side configuration. Assign the Fluxio-compatible address from Step 1 to relay_base and your Fluxio credential to relay_key.
Alternatively, set OPENAI_API_KEY and OPENAI_BASE_URL in the process environment, then construct OpenAI(). An explicit constructor base URL takes precedence over the environment setting, so avoid leaving a conflicting address in application code. ([github.com](https://github.com/openai/openai-python/blob/main/docs/architecture/security-model.md?utm_source=openai))
§3 Step 3: Configure the OpenAI JavaScript SDK
Install the package with npm install openai, then import it using import OpenAI from 'openai'. JavaScript uses different option names: apiKey and baseURL, not Python’s underscored equivalents. ([developers.openai.com](https://developers.openai.com/api/docs/libraries?utm_source=openai))
Create the client with new OpenAI({ apiKey: relayKey, baseURL: relayBase }). Supply the same relay credential and versioned base address used in Python. The SDK also recognizes OPENAI_API_KEY and OPENAI_BASE_URL when those constructor options are omitted. ([github.com](https://github.com/openai/openai-node))
Keep this client on your server. The JavaScript SDK disables browser use by default because exposing a secret API credential in browser code creates a security risk. Route browser requests through your own backend instead. ([github.com](https://github.com/openai/openai-node))
§4 Step 4: Configure the OpenAI Java SDK
Java exposes the base address through the builder’s baseUrl method. Configure an OpenAIOkHttpClient.builder() with .apiKey(relayKey) and .baseUrl(relayBase), then finish with .build(). Notice the lowercase final letters in baseUrl; copying JavaScript’s spelling will not produce the same builder call. ([developers.openai.com](https://developers.openai.com/api/reference/java?utm_source=openai))
For environment-based configuration, use .fromEnv(). The Java SDK supports OPENAI_BASE_URL and the system property openai.baseUrl; system properties take precedence over environment variables. Reuse the configured client rather than rebuilding its connection pool for every request. ([developers.openai.com](https://developers.openai.com/api/reference/java?utm_source=openai))
§5 Step 5: Validate One Request Before Enabling Streaming
Start with one short prompt and a model identifier confirmed in your relay account. For example, choose Gemini 2.5 Flash if available, but copy its exact API identifier rather than assuming its display name is accepted.
After the basic request succeeds, enable streaming. The OpenAI Python and JavaScript SDKs support streamed responses through stream=True and stream: true, respectively. Consume the returned events incrementally instead of waiting to display the completed response. ([github.com](https://github.com/openai/openai-python?utm_source=openai))
§6 Step 6: Check Routing and Compatibility Before Deployment
- – Inspect the resolved request address for a missing or duplicated version segment.
- – Confirm the application loads the relay credential alongside the relay address.
- – Verify the selected operation and model identifier against the relay’s supported API surface.
- – Test incremental output through your complete backend and frontend path.
Sign up for Fluxio to try your configured client.