Add Novita as a model gateway backend - #102
Open
jax-novita wants to merge 3 commits into
Open
Conversation
Novita hosts open-weight models behind its own OpenAI-compatible endpoint (api.novita.ai/openai), reached with a single NOVITA_API_KEY. Model ids are already author/slug (deepseek/deepseek-r1), the same shape OpenRouter uses, so no special-casing is needed in vendor(). Follows the existing openrouter/openai/ollama backends: a thin subclass of OpenAICompatChatModel, credentials resolved through the same env/.env lookup in config.py, and a new branch in the registry's get_model(). Like OpenAI, Novita reports no per-call cost, so calls are counted as unpriced unless a rate card is supplied.
The models listed for Novita were older ids that no longer reflect what the platform leads with. Point the recommendations at the three current flagships instead, each verified against api.novita.ai: moonshotai/kimi-k3 1M context, native vision zai-org/glm-5.2 1M context, long-horizon agentic work deepseek/deepseek-v4-flash-0731 1M context, cheapest of the three Context windows, output limits, input modalities and pricing were taken from the live /openai/v1/models response rather than carried over.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
novitaas a fifth OpenAI-wire backend, resolved through a newgrapharc/gateway/novita.py(NovitaChatModel, subclass ofOpenAICompatChatModel, same shape asopenrouter.py/ollama.py).https://api.novita.ai/openai) with a singleNOVITA_API_KEY, resolved through the existing env/.env credential lookup inconfig.py.novitainregistry.py's backend list andgateway/__init__.py's lazy-load mapping, and add anovitaextra topyproject.toml(langchain-openai, already a repo dependency — no new package).novitaintocli/probe.pyandcli/main.pysographarc models/grapharc models --checklist and probe it like the other backends.moonshotai/kimi-k3,zai-org/glm-5.2,deepseek/deepseek-v4-flash-0731) indocs/cookbook/02-models.md, each verified againstapi.novita.ai's live/openai/v1/modelsresponse.Model ids on Novita are already
author/slug(e.g.deepseek/deepseek-r1), the same shape OpenRouter uses, sovendor()needs no Novita-specific handling. Like OpenAI, Novita's chat-completions response carries no per-call cost, so calls are counted as unpriced (SpendMeter.unpriced_calls) unless a caller suppliesprice_per_million=.Testing
uv run pytest tests/test_gateway_novita.py tests/test_cli.py tests/test_cookbook_models.py tests/test_gateway_openai_ollama.py tests/test_gateway_openrouter.py— 263 passed, 10 deselected.uv run pytest(full suite) — 1986 passed, 13 skipped, 13 deselected. One pre-existing failure unrelated to this change:tests/test_cookbook_agents.py::test_snippet_runs_as_printed[02-confinement.py](/etc/passwdpath normalization in the sandbox), reproduced on the unmodified base tree.uv run ruff check grapharc tests— clean.