EN ▾

OpenAI Compatible API Tester: A 5-Minute Test Routine

You do not need a special openai compatible api tester to check an endpoint; curl and about forty lines of Python cover it. This routine takes five minutes and tells you whether auth, completions, streaming and limits behave the way your code expects.

Last updated

Summary

  • Run four checks in order: auth and model list, one completion, a stream, then deliberate error cases.
  • Look at headers as well as bodies: X-Request-Id, X-Balance-USD and the rate limit headers.
  • A test costs a fraction of a cent; the $0.50 trial credit covers thousands of small calls.
  • Provoke a 429 on purpose so you know your retry logic works before production does it for you.
A test bench with a probe and four checkpoint gates, representing an API endpoint test routine

Before you start

You need a key and a base URL. For this endpoint the base URL is https://api.apicompatibleopenai.com/v1 and the model id is uncensored. New users can claim $0.50 of trial credit with one click on the API key page after signing up with Google, or with email and password. The credit needs no card, is valid for seven days and is limited to one claim per person.

The trial key has lower limits than a full key: 2 concurrent requests and 60 requests per minute, against 8 and 300. That works in your favour for testing, because it lets you reach the limits without writing a load test.

Put the key in an environment variable so the commands below stay copy-paste friendly:

export KEY="YOUR_API_KEY"
export BASE="https://api.apicompatibleopenai.com/v1"
export MODEL="uncensored"

Check 1: authentication and the model list

The cheapest call is the model list. It confirms the URL, the key and the TLS connection without spending tokens.

# the list should include the model id "uncensored"
curl -i https://api.apicompatibleopenai.com/v1/models \
  -H "Authorization: Bearer $KEY"

The -i flag prints response headers. You should see a 200 status, a JSON list that includes uncensored, and headers such as X-Request-Id and X-Balance-USD. If the status is not 200, stop here: nothing later will work until this call does. The usual causes are a mistyped key, a missing /v1 in the URL, or a key copied with a trailing space.

Check 2: one completion

Now send a normal request and read the whole response, not only the text.

curl -i https://api.apicompatibleopenai.com/v1/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"Reply with exactly: ready"}],"temperature":0,"max_tokens":10}'

Check four things. The status is 200. choices[0].message.content holds text. finish_reason is present. usage lists prompt and completion tokens. Then look at X-Balance-USD and send the call again: the balance should drop by a tiny amount. A call with roughly 200 input tokens and 100 output tokens costs 200 x $0.15 / 1M plus 100 x $0.50 / 1M, which is $0.00003 plus $0.00005, or $0.00008. At that size the $0.50 trial pays for about 6,000 calls.

Check 3: streaming

Streaming is where proxies and buffering break things, so test it explicitly. With curl, add -N and "stream": true.

curl -N https://api.apicompatibleopenai.com/v1/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","stream":true,"messages":[{"role":"user","content":"List five colours."}]}'

You should see lines starting with data: arrive progressively, not all at once after a delay. If the output appears in one burst, something between you and the server is buffering, which matters for chat interfaces. The stream carries usage at the end, so a client that reads the last event can log token counts without a second call.

A reusable Python test script

The script below runs the same checks plus an error case and a concurrency probe. It uses only the OpenAI SDK and the standard library.

import threading
import time
from openai import OpenAI, APIStatusError

BASE = "https://api.apicompatibleopenai.com/v1"
client = OpenAI(base_url=BASE, api_key="YOUR_API_KEY", max_retries=0)

def check(name, fn):
    t = time.time()
    try:
        out = fn()
        print(f"PASS {name} ({time.time() - t:.2f}s): {out}")
    except Exception as e:
        print(f"FAIL {name}: {type(e).__name__}: {e}")

def models():
    return [m.id for m in client.models.list().data]

def completion():
    r = client.chat.completions.create(
        model="uncensored",
        messages=[{"role": "user", "content": "Say ok."}],
        max_tokens=5,
    )
    return r.choices[0].message.content

def stream():
    s = client.chat.completions.create(
        model="uncensored",
        messages=[{"role": "user", "content": "Count to three."}],
        stream=True,
    )
    return "".join(c.choices[0].delta.content or "" for c in s if c.choices)

def bad_key():
    bad = OpenAI(base_url=BASE, api_key="wrong-key", max_retries=0)
    try:
        bad.models.list()
    except APIStatusError as e:
        return f"rejected with HTTP {e.status_code}"
    raise RuntimeError("bad key was accepted")

for name, fn in [("models", models), ("completion", completion),
                 ("stream", stream), ("bad key", bad_key)]:
    check(name, fn)

# Concurrency probe: 3 parallel calls on a key limited to 2 at once
def worker(i, results):
    try:
        client.chat.completions.create(
            model="uncensored",
            messages=[{"role": "user", "content": "Write a 150 word story."}],
        )
        results[i] = "ok"
    except APIStatusError as e:
        results[i] = f"HTTP {e.status_code}"

results = {}
threads = [threading.Thread(target=worker, args=(i, results)) for i in range(3)]
for t in threads: t.start()
for t in threads: t.join()
print("concurrency probe:", results)

max_retries=0 matters here: the SDK retries some failures by default, which would hide the very errors you want to see.

Check 4: error cases worth provoking

A tester that only proves the happy path is half a tester. Provoke these deliberately and confirm your code handles them.

  • Bad key. The call must fail with an error status and no completion. The script above shows the code.
  • Too many concurrent requests. On a trial key the third parallel request should fail with HTTP 429 and the error code concurrency. Your code should wait and retry, not fail the user.
  • Too many requests per minute. Past 60 per minute on a trial key, or 300 on a full key, the answer is 429 with rate_limited.
  • Overload. A temporary 429 comes with Retry-After: 5. Honour that header.
  • Oversized body. The maximum is 8 MB, so a big payload should be rejected, not silently truncated.

Remember that failed or refused requests are not charged, so error testing costs nothing. Streams matter for the concurrency case: a streamed request occupies its slot until the stream ends, so a test that opens streams and never reads them will block the slots.

Turning the routine into a repeatable check

A test you run once proves little. Save the Python script from above in your repository and run it after each deploy, and on a schedule if the endpoint matters to your product. Keep the output, because a change in latency, wording or error shape is easier to spot against a record than against memory.

  • Use fixed prompts with temperature 0 and a seed, so a difference in output means something changed on the other side or in your request.
  • Keep test prompts free of real user data. A test prompt should be something you would be fine seeing in a log.
  • Run the limit tests rarely and on purpose. They are cheap, but they fill your concurrency slots for a moment and can fail other work running on the same key.
  • Alert on the status code and error code, not only on the text, so a 429 reads as a limit and a missing balance reads as a funding problem.

Check the balance header over time too. A run that spends noticeably more than the one before it usually means a longer prompt slipped into the test.

Testing tool calling and JSON mode

If your application uses function calls or structured output, add two more checks. They take a minute each and catch problems that plain completions hide.

For tool calling, send one tool definition and a prompt that clearly needs it, with tool_choice set to auto. Check that the reply has tool_calls with valid JSON in arguments. Then send the result back as a tool message and confirm you get a normal text answer. For JSON mode, set response_format to {"type":"json_object"}, ask for JSON in the prompt, and run the reply through a JSON parser. Do this ten times, not once, because the failures you care about are the rare ones.

Reading the results

Keep a short log of every run: date, request id, status, latency you measured yourself, and balance before and after. The X-Request-Id value is what support needs to find a specific call. When all four checks pass, you know the endpoint speaks the format your SDK expects. You do not yet know how it behaves at your real prompt sizes, so repeat check 2 with a prompt close to production length. The context window is 100,000 tokens for prompt plus completion.

When the tests pass, read the documentation for the full parameter list, and use the pricing page to turn your measured token counts into a monthly estimate. The pricing checklist walks through that estimate step by step.

Common questions

Is there an online tester for OpenAI-compatible endpoints?

You do not need one. curl and the official SDK with a changed base URL test the same things, and they use the exact client your application will use.

How much does testing cost?

Very little. A call with 200 input and 100 output tokens costs about $0.00008, so the $0.50 trial covers thousands of them. Failed requests are not charged.

Why does my test return 429 so quickly?

A trial key allows 2 concurrent requests and 60 per minute. Open streams count toward the concurrency limit until they end.

Which model id do I test with?

Use uncensored. The GET /v1/models call lists it, and it is the only model this API serves.

Get your key in one step

Sign up, copy your key, update your base URL. Done.

Start now

No subscription. Prepaid credit does not expire.