Relay365Multi-model API relay desk
← All desk bulletins
Wire & endpointsEN144 desk reads

OpenAI-Compatible API Basics for New Developers

Understand what an OpenAI-compatible API provides

An OpenAI-compatible API accepts request formats that follow the familiar OpenAI API conventions. This matters because you can often use existing OpenAI SDKs, examples, tools, and application code while choosing a compatible provider or model gateway. Instead of learning a completely different client interface for every model family, you configure a base URL, supply an API key, select a model, and send messages.

Relay365 is a pay-as-you-go relay desk for model families including Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, and Grok. Its OpenAI-compatible endpoint lets applications that already use an OpenAI client connect by setting the API base to https://api.api365relay.com/v1. Before building a feature, confirm the exact model identifier and supported endpoint in your account documentation, because available models and capabilities can differ.

Create an account and store the API key safely

Start by creating an account with the provider you plan to use, generating an API key, and keeping that key out of source control. An API key identifies your account to the service, so treat it like a password. Do not place it directly in frontend JavaScript, mobile applications, screenshots, public repositories, or shared chat messages.

For local development, put the key in an environment variable. A common name is OPENAI_API_KEY, although your project may use a provider-specific name. Your server reads the variable when it starts, then passes it to the SDK. In production, use your deployment platform's secret-management settings rather than committing a .env file.

Configure an OpenAI client with the compatible base URL

Most OpenAI SDKs let you provide two essential settings: the API key and the base URL. The base URL tells the client where requests should go. For Relay365, OpenAI clients add /v1 to the supplied API base, resulting in https://api.api365relay.com/v1.

Once configured, create a chat completion by sending a model name and a messages array. Messages normally include a role, such as system, user, or assistant, plus text content. A small first request is useful because it verifies authentication, networking, model access, and your client configuration before you build a larger workflow.

  • Use a system message to state stable behavior, such as asking the assistant to answer clearly and cite uncertainty when appropriate.
  • Use a user message for the task or question the person is currently asking.
  • Read the assistant response from the completion object returned by your SDK rather than assuming a raw text field.

Choose a model that matches the first task

Model selection is a product decision, not merely a configuration detail. Start with the quality, response speed, context needs, tool use, and cost characteristics your feature requires. For example, Gemini 2.5 Flash may be appropriate for an interactive prototype where you want to test short conversational tasks, while Claude Sonnet 5.5 may suit a more demanding writing or reasoning workflow. Test with representative inputs before deciding.

Keep the model name in configuration instead of scattering it across the codebase. That makes experiments and rollbacks easier. It also helps when one environment uses a less expensive model for development and another uses a model selected for production requirements. Record the model, prompt version, and relevant request settings when evaluating results.

Handle responses, failures, and usage deliberately

A successful response is only one possible outcome. Your application should also handle invalid credentials, unavailable models, malformed requests, rate limits, network interruptions, and responses that do not contain the content you expected. Show users a useful error message, log enough server-side context for diagnosis, and avoid logging secrets or sensitive prompt content unnecessarily.

Set reasonable timeouts and consider retrying transient failures with bounded backoff. Do not blindly retry every error: authentication and invalid-request failures generally need a configuration or code fix. For generated output, validate the format when your downstream system expects structured data. If a response must be JSON, ask for JSON and still verify it before processing it.

Connect compatible tools after the first request works

After a basic request succeeds, you can use the same compatible configuration in developer tools and applications that support OpenAI-style clients. Relay365 can fit teams using Claude Code, Codex, Gemini CLI, or any OpenAI SDK, provided the tool allows its endpoint and credentials to be configured. Make one small test request in each tool before relying on it for a larger task.

If Relay365 matches your need for pay-as-you-go access across model families, create an account and begin with a controlled test project. Members can also earn a referral bounty when people they invite make payments. Keep your first integration narrow, measure the outputs that matter to your application, and expand only after the basic request path is reliable.

Further desk bulletins

Curious how it runs on your own code? Sign up →