Skip to content

Add Novita as a model gateway backend - #102

Open
jax-novita wants to merge 3 commits into
CodeGraphContext:mainfrom
jax-novita:add-novita-provider
Open

Add Novita as a model gateway backend#102
jax-novita wants to merge 3 commits into
CodeGraphContext:mainfrom
jax-novita:add-novita-provider

Conversation

@jax-novita

Copy link
Copy Markdown

Summary

  • Add novita as a fifth OpenAI-wire backend, resolved through a new grapharc/gateway/novita.py (NovitaChatModel, subclass of OpenAICompatChatModel, same shape as openrouter.py/ollama.py).
  • Reach Novita's own OpenAI-compatible endpoint (https://api.novita.ai/openai) with a single NOVITA_API_KEY, resolved through the existing env/.env credential lookup in config.py.
  • Register novita in registry.py's backend list and gateway/__init__.py's lazy-load mapping, and add a novita extra to pyproject.toml (langchain-openai, already a repo dependency — no new package).
  • Wire novita into cli/probe.py and cli/main.py so grapharc models / grapharc models --check list and probe it like the other backends.
  • Recommend Novita's current flagship models (moonshotai/kimi-k3, zai-org/glm-5.2, deepseek/deepseek-v4-flash-0731) in docs/cookbook/02-models.md, each verified against api.novita.ai's live /openai/v1/models response.

Model ids on Novita are already author/slug (e.g. deepseek/deepseek-r1), the same shape OpenRouter uses, so vendor() 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 supplies price_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/passwd path normalization in the sandbox), reproduced on the unmodified base tree.
  • uv run ruff check grapharc tests — clean.

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.
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