A free OpenAI-compatible API, for code that needs a real /v1.

Updated 2026-07-16

Sometimes the requirement is not "a free model", it is "a /v1-shaped endpoint my SDK, framework, or CI pipeline can hit without a billing setup". The free routes that satisfy it: mock servers for shape testing, a local Ollama /v1 for offline inference, and a free starting credit here on a real gateway that serves every major family. Which one fits depends on whether your test needs real model behavior.

Quick answer: three free /v1 shapes, three different jobs.

The routes compose rather than compete: mature test suites mock the API in unit tests, run a local or hosted model in integration tests, and keep a small real smoke test in CI. The sections below cover when each layer earns its place, and where the free credit fits.

  • Mock servers and stubs: a fake /v1 that returns canned responses. Free forever, deterministic, instant, and completely blind to real model behavior. Right for unit tests and client plumbing.
  • Local inference with an OpenAI-compatible server: Ollama and llama.cpp expose /v1 on localhost, so the same client code runs against open-weight models on your own hardware. Free after the hardware, offline-friendly, capability-limited by what your GPU serves.
  • A real hosted /v1 with a free start: the starting credit here funds requests against the actual gateway at https://api.apisrouter.com/v1, no card required, with every catalog family addressable by id. Right for integration tests, smoke tests, and evaluating what the models actually do.

Mock vs real: what each layer can and cannot catch.

A mock catches contract drift: wrong request shape, missing headers, broken retry logic, mishandled streaming frames. Because it is deterministic and free, it belongs in every unit suite, and no billed endpoint should ever be in the hot path of a test that runs on every commit. What a mock cannot catch is everything that makes LLM integrations fail in production: tokenization pushing a prompt over the context limit, finish_reason values your code never handled, tool-call arguments arriving malformed, rate-limit behavior under parallelism, latency long enough to trip your timeouts. Those only surface against real inference, which is why a test pyramid with nothing but mocks ships surprises. The practical split: mock the API in unit tests; run a handful of real requests in an integration stage gated behind a secret; and keep one canary request in CI that calls the real endpoint with a tiny prompt and asserts on structure, not content. At value-model rates a daily CI smoke test costs effectively nothing, and the starting credit covers weeks of it before any money moves.

The real /v1 here: what the free credit funds.

APIsRouter exposes the standard OpenAI-compatible surface: /v1/chat/completions, /v1/models, /v1/embeddings, and an Anthropic-shaped /v1/messages for clients that speak that dialect. Any SDK or framework that accepts a base URL override works unchanged: the OpenAI Python and TypeScript SDKs, LangChain, LlamaIndex, and every tool covered in the integration guides on this site. The starting credit is issued without a card and meters the same catalog as paid traffic, which matters for testing in a specific way: the ids your tests exercise are the ids production will call. A test that passes against deepseek-v4-flash on the credit behaves identically when the same string ships, because nothing about the endpoint changes at the paid boundary. The first call worth making is not a completion at all. List the models, and let your test configuration pin exact ids from the response rather than hardcoding guesses.

curl -s https://api.apisrouter.com/v1/models \
  -H "Authorization: Bearer $APISROUTER_API_KEY" | head -40

The local route: Ollama's /v1 on your own hardware.

Ollama serves an OpenAI-compatible endpoint at localhost:11434/v1, which makes it the zero-marginal-cost option for development loops: unlimited requests, no network dependency, no key management, and full data locality. For CI it runs in a container, and for development it keeps the edit-run cycle instant. Its limits are the model catalog and the hardware. Consumer GPUs serve small and mid-size open-weight models; the frontier hosted families are simply not available locally, so tests that need their behavior, larger context windows, specific tool-calling reliability, a particular vendor's output habits, still need a hosted endpoint. The pairing most teams land on: Ollama for the inner loop, the gateway for the outer loop, both behind the same client code because both speak /v1.

Pay-as-you-go · transparent per-model pricing

Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.

ModelOfficial PriceOur Price
DeepSeek V4 Flash$0.14 / $0.28 per M$0.13 / $0.25 per M
GPT-5.4 Mini$0.75 / $4.50 per M$0.60 / $3.60 per M
GLM-5.2$1.14 / $4.00 per M$1.03 / $3.60 per M
Claude Sonnet 4.6$3.00 / $15.00 per M$2.40 / $12.00 per M
Gemini 3.5 Flash$1.50 / $9.00 per M$1.20 / $7.20 per M

Budgeting real calls in CI without surprises.

The anxiety behind "free" in a CI context is usually a runaway pipeline burning money at 3 a.m. Three habits make a real endpoint safe to wire in. Pin tiny prompts and tight max_tokens in test fixtures; a smoke test needs five tokens, not five hundred. Scope one key to CI, so the usage log doubles as the pipeline's cost ledger and a leaked key revokes without touching development. And prefer value-family ids for structural assertions: a contract test cares that the response parses, and deepseek-v4-flash proves that at the catalog's lowest rates, while the expensive ids stay reserved for the eval suite that actually measures quality. On the credit, all of this is free in the plain sense: the balance starts positive, spends slowly at smoke-test volumes, and converts to pay-as-you-go only when and if you top up. No subscription starts ticking, and an idle repo costs nothing.

Which free /v1 fits which job.

  • Unit tests, client plumbing, retry and streaming logic: a mock server. Deterministic and free forever.
  • Development inner loop, offline work, private data: Ollama's local /v1 on hardware you already own.
  • Integration tests against real model behavior, multi-family evaluation, CI smoke tests: the starting credit here, on the same /v1 production would use.
  • Sampling many hosted models casually: OpenRouter's :free variants, within their daily caps, covered in the roundup linked below.
  • Production traffic: metered pay-as-you-go. No free mechanism is built for production, and a /v1 that is free without limits does not exist.

FAQ

Is there a free OpenAI-compatible API?

Several, each with a catch: mock servers are free but fake, Ollama's local /v1 is free after hardware, OpenRouter serves capped :free variants, and the starting credit here funds requests against a real multi-family /v1 with no card. None is unlimited hosted inference, because that does not exist.

Can I use the free starting credit for CI pipelines?

Yes, and it fits the smoke-test layer well: tiny prompts against value ids cost a small fraction of a cent per run, the credit covers weeks of daily runs, and a CI-scoped key turns the usage log into the pipeline's cost ledger. Keep unit tests on mocks; spend real tokens only where model behavior matters.

Does the endpoint here work with the OpenAI SDK unchanged?

Yes. Set base_url to https://api.apisrouter.com/v1 and api_key to your key; chat completions, streaming, tool calls, and /v1/models work as the SDK expects. An Anthropic-shaped /v1/messages is also served for clients that speak that dialect.

Should I test against a mock or a real model?

Both, at different layers. Mocks catch contract drift deterministically and belong in every unit suite. Real calls catch tokenization limits, unexpected finish reasons, malformed tool calls, and latency behavior that mocks cannot represent. The standard shape is mocks per commit, real smoke tests per merge or per day.

What free route works fully offline?

Local inference: Ollama and llama.cpp expose an OpenAI-compatible /v1 on localhost and serve open-weight models bounded by your hardware. It pairs naturally with a hosted gateway for the models and context sizes local hardware cannot serve.

What happens when the free credit runs out?

The endpoint, key, and model ids stay the same; you top up a pay-as-you-go balance if you want to continue, and nothing bills if you stop. Tests written against the credit keep passing unmodified after the boundary, which is the point of evaluating on the production surface.