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

Request Headers That Matter for Model APIs

Start with a small request and a deliberate header checklist. Rather than copying every header from an example, work through the steps below: authenticate, describe the payload, select any required API version, and make the request traceable.

Match authentication headers to the endpoint

1. Identify which API protocol your endpoint accepts. OpenAI uses Authorization with a Bearer credential. Google's Gemini API supports API keys through x-goog-api-key. Native Claude requests support Authorization, with x-api-key also accepted. These are endpoint contracts, not interchangeable spellings for one universal header. Use the authentication method documented for the destination. ([developers.openai.com](https://developers.openai.com/api/reference/overview?utm_source=openai))

For an OpenAI request, the header takes the form Authorization: Bearer YOUR_API_KEY. Replace the placeholder locally; never paste a real credential into a tutorial, support ticket, or shared screenshot. Keep keys on your server in environment variables or a secrets manager rather than embedding them in browser code. ([developers.openai.com](https://developers.openai.com/api/reference/overview?utm_source=openai))

Describe the request body with Content-Type

2. For a JSON request, send Content-Type: application/json. This header describes the representation you are sending. It does not repair malformed JSON or validate the model name. If a request fails, inspect the serialized body separately from its headers. ([rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110.html))

Let your HTTP library handle multipart boundaries when uploading files. Do not force application/json onto every request simply because your first text-generation example used it. Content-Type should match the actual payload format. ([rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110.html))

Separate Accept from the streaming switch

3. Treat Accept as a response-format preference, not a generation setting. Accept: application/json expresses a preference for JSON; Accept: text/event-stream expresses a preference for an event stream. Neither replaces an endpoint's documented streaming controls. ([rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110.html))

For example, OpenAI's Responses API enables server-sent events by setting stream to true in the request body. Follow that contract rather than assuming an Accept header alone enables streaming. First test a non-streaming request, then enable streaming as a separate integration step. ([developers.openai.com](https://developers.openai.com/api/docs/guides/streaming-responses?utm_source=openai))

Add version and feature headers deliberately

4. Check whether the protocol requires a version header. Native Claude requests require anthropic-version, and its SDKs handle that header automatically. This selects API behavior; it is not the model identifier. ([platform.claude.com](https://platform.claude.com/docs/en/api/overview?erid=2W5zFJX2bW1&utm_source=openai))

The anthropic-beta header opts into specified experimental features. Add it only when a feature's documentation requires it, and verify support on your chosen route. Avoid copying a collection of beta headers into every application: keep each optional header tied to a feature you actually use. ([platform.claude.com](https://platform.claude.com/docs/en/api/beta-headers?utm_source=openai))

Connect request headers to troubleshooting records

5. Where supported, attach a client-generated identifier so you can investigate a failed call. OpenAI accepts X-Client-Request-Id and returns a server-generated x-request-id. These are different directions of metadata: one accompanies your request, while the other arrives in the response. ([developers.openai.com](https://developers.openai.com/api/reference/overview?utm_source=openai))

Record the request identifier alongside the timestamp and outcome, but redact credentials. OpenAI recommends logging request IDs for troubleshooting. Do not assume another provider or relay recognizes the same custom header; confirm its documented tracing behavior first. ([developers.openai.com](https://developers.openai.com/api/reference/overview?utm_source=openai))

Configure Relay365 without mixing protocol headers

6. Relay365 fits when you want pay-as-you-go access to multiple model families through one relay desk. It supports OpenAI-compatible and native provider routes, with integrations for Claude Code, Codex, and Gemini CLI. OpenAI clients use its API host with /v1 appended. Choose the route first, then apply that route's header requirements rather than combining every provider's authentication headers. ([api365relay.com](https://api365relay.com/))

If that workflow suits your project, create a Relay365 account and follow its integration runbook for your client. Keep your first test minimal, confirm authentication and payload handling, then add streaming, tracing, and optional features one at a time. This gives you a clear debugging sequence without turning headers into guesswork. ([api365relay.com](https://api365relay.com/en-us/runbook))

Further desk bulletins

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