OpenAI-Compatible Claude and Gemini: Normal and Streaming SDK Tests
Six SDK cases separate ordinary replies from complete streams. Five completed and one timed out; includes exact SDK version, runnable code and transport configuration.

An OpenAI-compatible endpoint can reuse the OpenAI SDK's request shape for selected Claude and Gemini routes. Compatibility must be checked by feature: an ordinary response, a complete stream and a tool round trip are different contracts. A configured base_url does not prove all of them work.
Crazyrouter is the gateway used in this six-case SDK matrix: all three ordinary responses completed, GPT and Claude streaming completed, and Gemini streaming timed out before any chunk arrived. The test used OpenAI Python SDK 2.35.1 with automatic retries disabled.
By Brian J · Tested November 3, 2026
Which OpenAI-compatible endpoint can I use for Claude and Gemini?#
This test configured the SDK with base URL https://api.crazyrouter.com/v1 and requested the Chat Completions operation. The application supplied a Crazyrouter key, not a native provider key. Each selected model had been checked in the credential's model catalog before the test.
The OpenAI Python library documents configurable clients and streamed responses. This article tests the gateway path directly; it does not transfer a compatibility claim to native Claude Messages, Gemini's native API, or OpenAI Responses. Compare those shapes in the protocol guide.
Normal and streaming output are separate checks#
On November 3, 2026, Python 3.10.2 used gpt-4.1-mini, claude-sonnet-4-6 and gemini-2.5-flash. Each request asked for BRIDGE-1471 with a 32-token limit. A pass required an exact marker and a final stop reason. A stream needed both accumulated text and a terminal finish reason.
| Model | Mode | Complete fixture | Chunks / error |
|---|---|---|---|
| gpt-4.1-mini | normal | Passed | Not applicable |
| gpt-4.1-mini | stream | Passed | 9 |
| claude-sonnet-4-6 | normal | Passed | Not applicable |
| claude-sonnet-4-6 | stream | Passed | 5 |
| gemini-2.5-flash | normal | Passed | Not applicable |
| gemini-2.5-flash | stream | Failed | APITimeoutError |
Observed response IDs (successful responses only):
chatcmpl-Eg6DUywd7mRW5C8rZ29yP1ViLJ7ql
chatcmpl-Eg6DWnCmvDXjoEsL2ceQLUVPppcbe
msg_011CgfrMqmA6x3G7SMTuuQYZ
msg_011CgfrMz4iqJSj7upADoi7p
chatcmpl-202611031039503123043898268d9d667UyNAk9

Chunk counts describe this run only. They are not a throughput measure and are not guaranteed across routes or repeated requests. The Gemini stream produced zero received chunks before APITimeoutError; there was no usable streamed answer to score.
Run the SDK compatibility matrix#
Install openai==2.35.1 and httpx, set CRAZYROUTER_API_KEY in the process environment, save this as compatibility_probe.py, and run it. The pinned version reproduces the tested SDK version; it is not a claim that this is the latest release.
"""Exercise normal and streaming SDK responses through a compatible endpoint."""
import importlib.metadata
import json
import os
import httpx
from openai import OpenAI, APIError
def main():
base='https://api.crazyrouter.com/v1'
client=OpenAI(api_key=os.environ['CRAZYROUTER_API_KEY'],base_url=base,max_retries=0,timeout=45,http_client=httpx.Client(trust_env=False))
rows=[]
for model in ['gpt-4.1-mini','claude-sonnet-4-6','gemini-2.5-flash']:
args={'model':model,'max_tokens':32,'messages':[{'role':'user','content':'Reply only BRIDGE-1471'}]}
try:
normal=client.chat.completions.create(**args)
rows.append({'model':model,'stream':False,'response_id':normal.id,'finish_reason':normal.choices[0].finish_reason,'output':normal.choices[0].message.content,'passed':normal.choices[0].finish_reason=='stop' and (normal.choices[0].message.content or '').strip()=='BRIDGE-1471'})
except APIError as error:
rows.append({'model':model,'stream':False,'passed':False,'error':type(error).__name__})
text=[];finish=None;response_id=None;chunks=0
try:
with client.chat.completions.create(**args,stream=True) as stream:
for chunk in stream:
response_id=chunk.id or response_id;chunks+=1
for choice in chunk.choices:
if choice.delta.content:text.append(choice.delta.content)
if choice.finish_reason:finish=choice.finish_reason
output=''.join(text)
rows.append({'model':model,'stream':True,'response_id':response_id,'finish_reason':finish,'chunks':chunks,'output':output,'passed':finish=='stop' and output.strip()=='BRIDGE-1471'})
except (APIError,httpx.HTTPError) as error:
rows.append({'model':model,'stream':True,'passed':False,'error':type(error).__name__,'received_chunks':chunks})
client.close()
print(json.dumps({'base_url':base,'sdk':'openai','sdk_version':importlib.metadata.version('openai'),'max_retries':0,'requests':rows}))
if __name__=='__main__':main()
The explicit HTTPX client sets trust_env=False to make the network route independent of proxy variables inherited by this test process. The first local attempt failed because an inherited proxy connection was refused. That was an environment failure before a useful compatibility result, and it is retained in the test notes. If your deployment requires a proxy, configure its working transport deliberately rather than copying this choice without review.
Record completion, not just the first chunk#
| Check | Ordinary response | Streaming response |
|---|---|---|
| Content | Read completed message content | Accumulate content deltas |
| Completion | Require final finish reason | Observe a terminal finish reason |
| Failure | Record route and error category | Retain partial-delivery state; do not claim completion |
| Crazyrouter test | Three completed responses | Two completed streams; one timeout |

The script records each matrix row independently. Zero process exit status means the diagnostic run completed, not that every row passed. It does not automatically repeat a failed stream; replay after partial delivery needs product-specific handling. See the bounded retry guide.
Expand the tested contract deliberately#
This matrix covers short text only. Test function calling, structured output, context length, images and usage reporting separately before relying on them.
The single-key catalog probe distinguishes account visibility from completed generation. A route can appear in a catalog and still fail for a particular request. Keep gateway model IDs, requested features and observed outcomes in configuration and monitoring rather than maintaining a single “compatible” boolean.
For authentication and operational diagnostics, retain minimal receipts without printing the key or customer text. The sample's fixed marker is synthetic, and its response IDs identify only these tests. No reliability ranking, billed-cost comparison or native-provider equivalence was established.
FAQ#
Is OpenAI compatibility the same as using OpenAI's service?#
No. It describes a request/response contract. This test used a gateway base URL and gateway credential.
Did Claude and Gemini both work with the SDK?#
Both completed ordinary responses. Claude streaming completed; Gemini streaming timed out in this matrix.
Does receiving a chunk mean a stream succeeded?#
No. Verify the accumulated answer and terminal finish reason. Partial output needs its own failure handling.
Why disable automatic retries?#
It makes each observed SDK attempt explicit in this small matrix. Production retries still require a deliberate policy.
Must I disable proxy environment variables?#
No. That setting isolated this test from a refused inherited proxy. Deployments that require a proxy should configure a valid one.
Can I infer native API support from these results?#
No. Native interfaces and additional features require their own tests.
Implementation Guides
Podcast
AI Dev Tools: The Crazyrouter Podcast
Short episodes for developers on AI APIs, gateways, cost control and coding tools.
Latest episodes
EP196 · Oct 29, 2026 · 6:53
AI API Security Posture — Turn Controls Into Continuous Evidence
A practical guide to AI API security posture: inventory exposure, verify controls continuously, protect keys and data, constrain tools, and turn security assumptions into evidence that operators can act on.
EP195 · Oct 28, 2026 · 7:21
AI API Policy Drift — Detect When Production Rules Stop Matching Intent
A practical guide to policy drift in AI APIs: version routing and safety rules, detect stale enforcement, compare intended and observed behavior, and restore control before small gaps become incidents.





