Skip to content

Add OpenRouter real-API integration test (free-tier path)#8

Merged
OmkarRayAI merged 1 commit into
mainfrom
feat/openrouter-integration-test
Jun 4, 2026
Merged

Add OpenRouter real-API integration test (free-tier path)#8
OmkarRayAI merged 1 commit into
mainfrom
feat/openrouter-integration-test

Conversation

@OmkarRayAI

Copy link
Copy Markdown
Owner

Summary

OpenRouter is OpenAI-protocol-compatible and offers free-tier models. Pointing the openai SDK at openrouter.ai/api/v1 verifies wikitrace.openai.patch over a real network — without burning OpenAI credits. Adds the most contributor-friendly real-API test path.

Why on top of the existing OpenAI test

  • Skip-default: contributors usually have an OpenRouter key (free signup, no card) before they have an OpenAI key (paid). This is the cheap end-to-end check.
  • Pricing path: OpenRouter returns model IDs in <provider>/<model> form. That exercises the recent wikitrace.pricing prefix-stripping fix end-to-end, which the bare OpenAI test does not.

What

  • tests/integration/test_openrouter_real.py — sync non-streaming + sync streaming, asserts span shape (provider, slash-form model, tokens, latency, retry, cost_usd present)
  • tests/integration/conftest.pyopenrouter_key fixture
  • .github/workflows/ci-real-api.yml — third job openrouter, gated on OPENROUTER_API_KEY secret + vars.WIKITRACE_OPENROUTER_TESTS_ENABLED
  • README.md — Tests section now lists OpenRouter first as the free-tier path

Verified locally

pytest -q tests/ → 88 passed, 14 skipped (the 2 new OpenRouter tests skip cleanly without OPENROUTER_API_KEY).

To activate

Settings → Secrets → Actions → New repository secret
  OPENROUTER_API_KEY=sk-or-...

Then trigger via Actions tab → "ci-real-api" → "Run workflow", or wait for the weekly cron.

Test plan

  • CI green on this PR (default suite still skips integration tests)
  • Add OPENROUTER_API_KEY repo secret (free signup at openrouter.ai)
  • Manually dispatch ci-real-api; confirm openrouter job goes green

🤖 Generated with Claude Code

OpenRouter is OpenAI-protocol-compatible and offers free-tier models,
so pointing the openai SDK at openrouter.ai/api/v1 verifies
wikitrace.openai.patch over a real network without burning credits.

Why on top of the OpenAI test:
- Skip-default contributors usually have an OpenRouter key (free)
  before they have an OpenAI key (paid). Free-tier models like
  mistralai/mistral-small-3.2-24b-instruct:free pay nothing.
- The OpenRouter <provider>/<model> id form exercises the recent
  pricing prefix-stripping fix end-to-end, which the bare OpenAI
  test does not.

tests/integration/test_openrouter_real.py
- Sync non-streaming + sync streaming
- Asserts provider, model (slash form), prompt_chars, tokens, latency,
  retry_count, and that cost_usd is set (None or 0.0 is acceptable
  on :free models)
- conftest gains an openrouter_key fixture; default model overrideable
  via WIKITRACE_OPENROUTER_TEST_MODEL env

ci-real-api.yml
- Third job openrouter, mirrors the openai/anthropic shape: reads
  OPENROUTER_API_KEY from repo secrets, exits 0 cleanly when absent
- Gateable via vars.WIKITRACE_OPENROUTER_TESTS_ENABLED

README
- Tests section now lists OpenRouter first as the free-tier path

Verified locally: pytest -q tests/ → 88 passed, 14 skipped (the 2 new
OpenRouter tests skip cleanly without a key).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@OmkarRayAI OmkarRayAI merged commit f3a7b22 into main Jun 4, 2026
4 checks passed
@OmkarRayAI OmkarRayAI deleted the feat/openrouter-integration-test branch June 4, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant