mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix: move Nanobridge live tests to llm_translation; remove in-repo docs
This commit is contained in:
parent
e2bc9d9ec3
commit
d067d1adeb
3 changed files with 32 additions and 116 deletions
|
|
@ -1,93 +0,0 @@
|
|||
# Nanobridge
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Provider** | `nanobridge` |
|
||||
| **API key env** | `NANOBRIDGE_API_KEY` |
|
||||
| **Base override env** | `NANOBRIDGE_API_BASE` (optional) |
|
||||
|
||||
Nanobridge is an OpenAI-compatible API gateway for Tencent Hunyuan model routes (DeepSeek, GLM, MiniMax, etc.). It also exposes an Anthropic Messages-compatible base for Claude Code and similar agents.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
export NANOBRIDGE_API_KEY="your-api-key"
|
||||
```
|
||||
|
||||
```python
|
||||
import litellm
|
||||
|
||||
response = litellm.completion(
|
||||
model="nanobridge/deepseek-v4-flash",
|
||||
messages=[{"role": "user", "content": "Hello"}],
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
## Regional endpoints
|
||||
|
||||
Three regions share the same API key and billing. Pick the closest node for lower latency.
|
||||
|
||||
| Region | OpenAI base (`/v1`) | Anthropic base |
|
||||
|--------|---------------------|----------------|
|
||||
| Germany (default) | `https://api.nanobridge.net/v1` | `https://api.nanobridge.net/anthropic` |
|
||||
| Singapore | `https://api-sg.nanobridge.net/v1` | `https://api-sg.nanobridge.net/anthropic` |
|
||||
| United States | `https://api-us.nanobridge.net/v1` | `https://api-us.nanobridge.net/anthropic` |
|
||||
|
||||
Override the default Germany URL:
|
||||
|
||||
```bash
|
||||
export NANOBRIDGE_API_BASE="https://api-sg.nanobridge.net/v1"
|
||||
```
|
||||
|
||||
## Supported models
|
||||
|
||||
Use `nanobridge/<model_id>` in LiteLLM:
|
||||
|
||||
| Model ID | Notes |
|
||||
|----------|--------|
|
||||
| `deepseek-v4-flash` | Recommended default |
|
||||
| `deepseek-v4-pro` | |
|
||||
| `deepseek-v3.2` | |
|
||||
| `glm-5.1` | Alias: `glm-5-1` |
|
||||
| `minimax-m2.7` | Alias: `minimax-m-2-7` |
|
||||
|
||||
## API paths
|
||||
|
||||
- Chat: `POST /chat/completions` or `POST /v1/chat/completions`
|
||||
- Models: `GET /v1/models`
|
||||
- Anthropic: `POST /v1/messages` on the Anthropic base
|
||||
- Streaming: `stream: true` (SSE)
|
||||
- Auth: `Authorization: Bearer <API_KEY>`
|
||||
|
||||
## LiteLLM Proxy
|
||||
|
||||
```yaml
|
||||
model_list:
|
||||
- model_name: nanobridge-deepseek-flash
|
||||
litellm_params:
|
||||
model: nanobridge/deepseek-v4-flash
|
||||
api_key: os.environ/NANOBRIDGE_API_KEY
|
||||
# api_base: os.environ/NANOBRIDGE_API_BASE
|
||||
```
|
||||
|
||||
## OpenAI Python SDK
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
import os
|
||||
|
||||
client = OpenAI(
|
||||
api_key=os.environ["NANOBRIDGE_API_KEY"],
|
||||
base_url="https://api.nanobridge.net/v1",
|
||||
)
|
||||
client.chat.completions.create(
|
||||
model="deepseek-v4-flash",
|
||||
messages=[{"role": "user", "content": "Hello"}],
|
||||
)
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Nanobridge API documentation](https://platform.nanobridge.net/#/api-docs)
|
||||
- [Platform console](https://platform.nanobridge.net)
|
||||
27
tests/llm_translation/test_nanobridge.py
Normal file
27
tests/llm_translation/test_nanobridge.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""
|
||||
Integration tests for Nanobridge (real API calls).
|
||||
|
||||
Requires NANOBRIDGE_API_KEY. Not collected in mock-only CI for tests/test_litellm/.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, os.path.abspath("../.."))
|
||||
|
||||
import litellm
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.environ.get("NANOBRIDGE_API_KEY"),
|
||||
reason="NANOBRIDGE_API_KEY not set",
|
||||
)
|
||||
def test_nanobridge_live_chat_completions():
|
||||
response = litellm.completion(
|
||||
model="nanobridge/deepseek-v4-flash",
|
||||
messages=[{"role": "user", "content": "Reply with exactly: ok"}],
|
||||
max_tokens=16,
|
||||
)
|
||||
assert response.choices[0].message.content
|
||||
|
|
@ -1,23 +1,19 @@
|
|||
"""
|
||||
Unit tests for Nanobridge JSON-configured OpenAI-compatible provider.
|
||||
Mock-only unit tests for Nanobridge JSON-configured OpenAI-compatible provider.
|
||||
Live / network tests: tests/llm_translation/test_nanobridge.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import pytest
|
||||
except ImportError:
|
||||
pytest = None
|
||||
|
||||
workspace_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../.."))
|
||||
sys.path.insert(0, workspace_path)
|
||||
|
||||
import litellm
|
||||
from litellm import LlmProviders
|
||||
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
workspace_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../.."))
|
||||
sys.path.insert(0, workspace_path)
|
||||
|
||||
|
||||
class TestNanobridgeProvider:
|
||||
def test_nanobridge_in_llm_providers_enum(self):
|
||||
|
|
@ -60,17 +56,3 @@ class TestNanobridgeProvider:
|
|||
mock_response="PONG",
|
||||
)
|
||||
assert response.choices[0].message.content == "PONG"
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.environ.get("NANOBRIDGE_API_KEY"),
|
||||
reason="NANOBRIDGE_API_KEY not set",
|
||||
)
|
||||
class TestNanobridgeLive:
|
||||
def test_nanobridge_live_chat_completions(self):
|
||||
response = litellm.completion(
|
||||
model="nanobridge/deepseek-v4-flash",
|
||||
messages=[{"role": "user", "content": "Reply with exactly: ok"}],
|
||||
max_tokens=16,
|
||||
)
|
||||
assert response.choices[0].message.content
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue