OpenAI compatibility starts with the request format
An OpenAI-compatible endpoint lets an application use familiar OpenAI-style requests to access models through another service. Instead of rebuilding your integration for every provider, you can often keep your SDK and change its configuration.
The important word is compatible, not identical. A service might support chat messages and streaming while handling tools, structured output, images, or newer API resources differently. Treat compatibility as a checklist of supported features, not a promise that every OpenAI example will work unchanged.
Separate the host, base URL, and API route
The host identifies the service. The base URL adds any shared API prefix. The route identifies a particular operation. Confusing these three pieces is a common first-run mistake.
- Host: https://api.fastapirelay.com
- OpenAI SDK base URL: https://api.fastapirelay.com/v1
- Example operation route: /chat/completions, appended by the SDK when you call its chat completions method.
With SwiftRelay, configure OpenAI SDKs with the base URL ending in /v1. Claude Code and Gemini CLI take the bare host instead. Follow each client's setup instructions rather than copying one URL into every tool. Check that your final request path does not accidentally contain /v1/v1.
Configure credentials and an exact model identifier
Most OpenAI-compatible SDK setups need three values: an API key, a base URL, and a model identifier. Use the key issued by the service receiving the request. An OpenAI account key does not automatically authenticate with a separate relay.
Keep keys in environment variables or a secrets manager, and make requests from your backend rather than exposing credentials in browser code. Never commit keys to source control or paste them into public debugging reports.
Copy the exact model identifier from the service's current documentation or model list. A display name such as Gemini 2.5 Flash is not necessarily the string accepted in the model field. Model availability and supported options also depend on the endpoint.
Make one plain-text request before adding features
Start with one short user message and a modest output limit using the parameter supported by your chosen endpoint. Confirm that authentication succeeds, the model resolves, and the response contains usable text. This isolates configuration problems before your application adds complexity.
Do not assume that changing the base URL makes every SDK resource available. Chat Completions and Responses are distinct API interfaces. If an example uses Responses, verify support explicitly; otherwise, start with the interface documented by the service.
Test streaming, tools, and structured output separately
Once plain text works, enable capabilities one at a time. This makes failures easier to diagnose and keeps unsupported options out of your baseline request.
- Streaming: Handle incremental chunks, completion signals, interrupted connections, and cancellation. Do not assume each chunk contains a complete message.
- Tool calling: Validate arguments and authorize actions in your application. A model's tool request is not permission to execute it.
- Structured output: Check which schema options are supported, then validate returned data before using it.
- Usage reporting: Confirm where token counts appear, including whether streaming requires an additional option.
Set retry rules and spending guardrails
Inspect status codes and error bodies before retrying. Invalid credentials and unsupported parameters need fixes, not repeated requests. For transient failures or rate limits, use bounded retries with backoff and respect retry guidance when provided.
A dropped connection does not prove that generation never started. Retrying may create another billable request, so avoid unlimited retries. Log request identifiers, model identifiers, token usage, and errors without recording secrets or unnecessary personal data.
Choose a relay with a small first-run test
SwiftRelay is a practical option when you want a pay-as-you-go relay for multiple model families through an OpenAI-compatible SDK. Billing is per token, so test representative prompts and outputs before estimating production costs.
Sign up for SwiftRelay to use the small gift credit available to new accounts for an initial integration check. Keep your endpoint configuration centralized and rerun your capability checklist whenever you change models, SDK versions, or API interfaces.