Skip to content

feat(provider): Add Hanzo provider as OpenAI Compatible - #30197

Closed
abhicris wants to merge 5 commits into
BerriAI:litellm_oss_110626from
abhicris:feat/hanzo-provider
Closed

feat(provider): Add Hanzo provider as OpenAI Compatible#30197
abhicris wants to merge 5 commits into
BerriAI:litellm_oss_110626from
abhicris:feat/hanzo-provider

Conversation

@abhicris

Copy link
Copy Markdown

What

Adds Hanzo (hanzo/) as a JSON-configured OpenAI-compatible provider. Mirrors the same shape as the recently-merged Neosantara (#29646) and Tensormesh (#29063) entries.

  • Provider route: hanzo/
  • Base URL: https://api.hanzo.ai/v1
  • Auth: HANZO_API_KEY (Bearer token, OpenAI-style). HANZO_API_BASE overrides the default base URL.
  • Endpoint: /v1/chat/completions
  • max_completion_tokens -> max_tokens param mapping.

Hanzo Cloud (hanzo.ai) is an OpenAI-compatible AI gateway. This PR covers Hanzo's native Zen model family; other upstream models routed through Hanzo's gateway can be reached by passing the upstream id under the hanzo/ prefix.

Files

  • litellm/llms/openai_like/providers.jsonhanzo entry
  • litellm/types/utils.pyLlmProviders.HANZO
  • litellm/constants.py — base URL, provider_list entry
  • provider_endpoints_support.json + litellm/provider_endpoints_support_backup.jsonhanzo capability entry
  • model_prices_and_context_window.jsonhanzo/zen4 ($1.50 / $4.50 per MTok), hanzo/zen4-max ($3 / $12 per MTok, 1M context)
  • docs/my-website/docs/providers/hanzo.md — provider docs page
  • tests/test_litellm/llms/openai_like/test_hanzo_provider.py — provider config + cost map unit tests

Test plan

  • JSON files parse
  • LlmProviders.HANZO resolves and is in litellm.provider_list
  • JSONProviderRegistry.exists("hanzo") and config fields match
  • get_llm_provider("hanzo/zen4") returns base URL https://api.hanzo.ai/v1
  • litellm.cost_per_token for hanzo/zen4 and hanzo/zen4-max returns the expected values
  • Custom api_base / api_key overrides the default

emerzon and others added 5 commits June 11, 2026 08:59
…re) (BerriAI#29775)

* Add gpt-realtime-whisper Realtime transcription support (OpenAI + Azure)

Adds first-class support for the gpt-realtime-whisper streaming speech-to-text
model, which uses the Realtime transcription session API rather than the
file-based /audio/transcriptions path.

Model registration: registers gpt-realtime-whisper and azure/gpt-realtime-whisper
with audio-duration pricing (input_cost_per_second = 0.017/60, matching the
published $0.017/minute input audio rate).

REST endpoint: implements POST /v1/realtime/transcription_sessions (plus /realtime
and /openai/v1 aliases) to mint an ephemeral transcription session for the
WebRTC flow. Adds request/response types, OpenAI and Azure URL builders, a shared
base handler (refactored from the client_secrets handler), the
acreate_realtime_transcription_session SDK function, and route registration. The
proxy encrypts the ephemeral key returned under client_secret.value and records
the session type in the token so the follow-up /realtime/calls replays
type=transcription rather than type=realtime.

WebSocket: forwards intent=transcription through to the Azure handler (OpenAI
already received it) with URL-encoding, so gpt-realtime-whisper opens a
transcription session. Transcription-only sessions no longer trigger an
erroneous response.create.

Cost tracking: transcription sessions emit no response.done events; their usage
arrives on conversation.item.input_audio_transcription.completed as
{type: duration, seconds}. That usage is captured out-of-band (usage only, no
transcript duplication) and billed by input_cost_per_second, with a token-billed
fallback for token-priced transcription models.

Adds tests for pricing math, URL builders, request/response types, the proxy
route and SDK function, WebSocket intent forwarding, transcription-session
streaming behavior, and the /realtime/calls session-type replay.

* Address PR review: URL-encode all Azure WS query params; forward query_params through provider_config branch

* Address PR review: session_type validation, model auth fix, cost perf, billing fallback, detail/docs cleanup

* Improve test coverage: detection from backend, error paths, unknown usage type, resolved_model None

* Backport realtime transcription websocket fixes

* Enforce authorized realtime transcription model

* Enforce realtime transcription model access

* Enforce realtime resolved model scopes

* Enforce WebRTC transcription model scope
* Pass through debug lazy logging

* fix(proxy): convert remaining eager pass-through debug logs to lazy formatting
…nt (BerriAI#30157)

* fix(parallel_ai): migrate search integration from v1beta to v1 endpoint

The Parallel Search API moved from /v1beta/search (processor: base/pro,
parallel-beta header) to /v1/search (mode: turbo/basic/advanced, no beta
header). Request fields moved too: max_results, source_policy, and excerpt
settings are now nested under advanced_settings, and source_policy uses
include_domains/exclude_domains. The v1 response returns publish_date per
result, which now maps to SearchResult.date instead of being hardcoded to
None. The legacy processor param is mapped to the equivalent mode so
existing callers keep working.

* fix(parallel_ai): default mode to basic and simplify param handling

The v1 API defaults to advanced mode when mode is omitted, while v1beta
defaulted to the base processor. Without an explicit default, callers who
pass no mode would be silently upgraded to a tier costing 2.25x more while
litellm's cost map reports the basic-tier price. Sending mode=basic
preserves the v1beta default and keeps cost tracking accurate.

Also replaces the handled_params set with pop-as-consumed param handling so
mapped params no longer need to be tracked in two places, and extends the
tests to pin the default mode, processor=base mapping, mode-over-processor
precedence, and top-level v1 param passthrough.

* fix(parallel_ai): avoid double /v1 when api_base is already versioned

A PARALLEL_AI_API_BASE like https://api.parallel.ai/v1 previously produced
.../v1/v1/search. Strip a trailing /v1 before appending the search path and
cover the api_base variants with a parametrized test.

---------

Co-authored-by: shin-berri <shin-laptop@berri.ai>
Co-authored-by: yuneng-jiang <yuneng@berri.ai>
Adds `hanzo/` provider routing to api.hanzo.ai. Mirrors the OpenAI v1
chat-completions interface via the existing JSON-configured provider
path (same shape as Neosantara / Tensormesh / Parasail). Auth via
HANZO_API_KEY env var; api_base overridable via HANZO_API_BASE.

Includes:
- providers.json entry with base_url, api_key_env, api_base_env,
  max_completion_tokens -> max_tokens param mapping, and
  /v1/chat/completions supported endpoint
- LlmProviders.HANZO enum entry
- constants.py wiring (openai_compatible_endpoints, provider_list)
- provider_endpoints_support.json + backup entries
- Model cost map entries for hanzo/zen4 (\$1.50/\$4.50 per MTok) and
  hanzo/zen4-max (\$3/\$12 per MTok, 1M context)
- Docs page at docs/my-website/docs/providers/hanzo.md
- Provider + cost-map unit tests under
  tests/test_litellm/llms/openai_like/test_hanzo_provider.py

Hanzo Cloud (hanzo.ai) is an OpenAI-compatible AI gateway that also
fronts ~444 models from ~56 underlying providers via a unified
/v1/chat/completions surface. This PR covers the Hanzo native Zen
family; other upstream models are reachable by passing the upstream
model id through Hanzo's gateway under the hanzo/ prefix.
@Sameerlite
Sameerlite force-pushed the litellm_oss_110626 branch from 160409f to 516a4e7 Compare June 11, 2026 10:16
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
4 out of 5 committers have signed the CLA.

✅ emerzon
✅ s-jag
✅ nina-hu
✅ pghuge-cloudwiz
❌ abhicris
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Hanzo (hanzo/) as a JSON-configured OpenAI-compatible provider, following the same pattern as the recently-merged Neosantara and Tensormesh entries. The integration covers provider registration, routing, capability flags, and pricing for two Zen models.

  • providers.json, constants.py, and types/utils.py wire up the provider route, API key/base env vars, and max_completion_tokens → max_tokens param mapping correctly.
  • model_prices_and_context_window.json registers hanzo/zen4 and hanzo/zen4-max with pricing, context windows, and capability flags using the JSON cost-map approach (not hardcoded logic).
  • docs/my-website/docs/providers/hanzo.md is added here but should live in the litellm-docs repo per project rules.

Confidence Score: 4/5

The provider integration itself is correct and follows established patterns; the only issue is a documentation file that should not be committed to this repository.

The core provider wiring — JSON config, enum registration, constants, cost map — is clean and mirrors the neosantara/tensormesh shape faithfully. The test suite uses only in-process, mock-based assertions with no real network calls. The one problem is docs/my-website/docs/providers/hanzo.md: project rules require provider docs to live in the litellm-docs repo, not here. Removing that file would leave this PR ready to merge.

docs/my-website/docs/providers/hanzo.md — this file should be moved to the litellm-docs repository.

Important Files Changed

Filename Overview
docs/my-website/docs/providers/hanzo.md New provider docs page added — violates the project rule that docs belong in the litellm-docs repo, not in this repository.
litellm/llms/openai_like/providers.json Adds hanzo entry with correct base URL, key/base env vars, param mappings, and supported endpoint — matches the pattern of neosantara/tensormesh peers.
litellm/constants.py Adds https://api.hanzo.ai/v1 to openai_compatible_endpoints and "hanzo" to openai_compatible_providers — consistent with other JSON-configured providers.
litellm/types/utils.py Adds HANZO = "hanzo" enum entry in the correct position among other JSON-configured providers.
model_prices_and_context_window.json Adds hanzo/zen4 ($1.50/$4.50 per MTok, 200k ctx) and hanzo/zen4-max ($3/$12 per MTok, 1M ctx) with capability flags stored in JSON per the model-flags rule.
provider_endpoints_support.json Adds hanzo capability entry (chat_completions only) consistent with other providers in the same JSON.
litellm/provider_endpoints_support_backup.json Backup mirror of provider_endpoints_support.json — hanzo entry is identical to the main file, no issues.
tests/test_litellm/llms/openai_like/test_hanzo_provider.py All tests use mocked data (monkeypatched cost map, in-process registry lookups, Router with a fake key) with zero real network calls — satisfies the no-real-network-calls rule.

Reviews (1): Last reviewed commit: "feat(provider): add Hanzo as an OpenAI-c..." | Re-trigger Greptile

@@ -0,0 +1,176 @@
import Tabs from '@theme/Tabs';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Documentation file belongs in the litellm-docs repo

Per the project's contribution rules, provider documentation pages must not be added to this repository — they need to live in the litellm-docs repo. Please remove this file from the PR and open a corresponding PR in litellm-docs instead.

Rule Used: Prevent documentation from being added - needs to ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@Sameerlite

Copy link
Copy Markdown
Contributor

Thanks for adding Hanzo support, @abhicris! A few things to address before this is ready:

  1. Merge conflicts — the branch has conflicts with the base. Could you rebase from main?
  2. CI is failing — could you check and either fix the failures or let us know if they're pre-existing?
  3. Proof of working — could you add some captured evidence? A quick curl completion call through the Hanzo provider, or a test run terminal capture, would complete the picture.
  4. Greptile scored 4/5 with a note that litellm/provider_endpoints_support_backup.json should be updated alongside the provider changes. Could you take a look?

Thanks for the contribution!

@mateo-berri
mateo-berri deleted the branch BerriAI:litellm_oss_110626 June 12, 2026 05:30
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.

8 participants