Skip to content

Commit 6fb2634

Browse files
study8677claude
andcommitted
feat: add NVIDIA Kimi K2.5 demo + fix Hub model routing for custom endpoints
- Fix create_model() to route custom base URLs through litellm (NVIDIA, Ollama, etc.) even when OPENAI_API_KEY is also set — previously the Agent SDK failed with "Unknown prefix: moonshotai" - Add "Real-World Demo: NVIDIA API + Kimi K2.5" section to all 3 READMEs with tested ag refresh / ag ask / ag report / ag log-decision output - Add test case for base_url + api_key routing (NVIDIA scenario) - Verified end-to-end: scanner → Hub pipeline → conventions.md generation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1bf5088 commit 6fb2634

5 files changed

Lines changed: 190 additions & 9 deletions

File tree

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,58 @@ See [Sandbox docs](docs/en/SANDBOX.md).
269269

270270
---
271271

272+
## Real-World Demo: NVIDIA API + Kimi K2.5
273+
274+
Tested end-to-end with [Moonshot Kimi K2.5](https://build.nvidia.com/moonshotai/kimi-k2-5) via NVIDIA's free API tier. Any OpenAI-compatible endpoint works the same way.
275+
276+
**1. Configure `.env`**
277+
278+
```bash
279+
OPENAI_BASE_URL=https://integrate.api.nvidia.com/v1
280+
OPENAI_API_KEY=nvapi-your-key-here
281+
OPENAI_MODEL=moonshotai/kimi-k2.5
282+
```
283+
284+
**2. Scan your project**
285+
286+
```bash
287+
$ ag refresh --workspace .
288+
Updated .antigravity/conventions.md
289+
```
290+
291+
Generated output (by Kimi K2.5):
292+
```markdown
293+
# Project Conventions
294+
## Primary Language & Frameworks
295+
- **Language**: Python (5,135 files, 99%+ of codebase)
296+
- **Infrastructure**: Docker, Docker Compose
297+
- **CI/CD**: GitHub Actions
298+
...
299+
```
300+
301+
**3. Ask questions**
302+
303+
```bash
304+
$ ag ask "What LLM backends does this project support?"
305+
Based on the context, the project supports NVIDIA API with Kimi K2.5.
306+
The architecture uses OpenAI-compatible format, supporting any endpoint
307+
including local LLMs via LiteLLM, NVIDIA NIM models, etc.
308+
```
309+
310+
**4. Log decisions (no LLM needed)**
311+
312+
```bash
313+
$ ag report "Auth module needs refactoring"
314+
Logged report to .antigravity/memory/reports.md
315+
316+
$ ag log-decision "Use PostgreSQL" "Team has deep expertise"
317+
Logged decision to .antigravity/decisions/log.md
318+
```
319+
320+
> Works with any OpenAI-compatible provider: **NVIDIA**, **OpenAI**, **Ollama**, **vLLM**, **LM Studio**, **Groq**, etc.
321+
322+
---
323+
272324
## Documentation
273325

274326
| | |

README_CN.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,58 @@ result = swarm.execute("构建并审查一个计算器")
269269

270270
---
271271

272+
## 实战演示:NVIDIA API + Kimi K2.5
273+
274+
使用 [Moonshot Kimi K2.5](https://build.nvidia.com/moonshotai/kimi-k2-5) 通过 NVIDIA 免费 API 进行端到端测试。任何 OpenAI 兼容端点都可以同样使用。
275+
276+
**1. 配置 `.env`**
277+
278+
```bash
279+
OPENAI_BASE_URL=https://integrate.api.nvidia.com/v1
280+
OPENAI_API_KEY=nvapi-your-key-here
281+
OPENAI_MODEL=moonshotai/kimi-k2.5
282+
```
283+
284+
**2. 扫描你的项目**
285+
286+
```bash
287+
$ ag refresh --workspace .
288+
Updated .antigravity/conventions.md
289+
```
290+
291+
Kimi K2.5 生成的输出:
292+
```markdown
293+
# Project Conventions
294+
## Primary Language & Frameworks
295+
- **Language**: Python (5,135 files, 99%+ of codebase)
296+
- **Infrastructure**: Docker, Docker Compose
297+
- **CI/CD**: GitHub Actions
298+
...
299+
```
300+
301+
**3. 提问**
302+
303+
```bash
304+
$ ag ask "这个项目支持哪些 LLM 后端?"
305+
根据上下文,项目支持通过 NVIDIA API 使用 Kimi K2.5。
306+
架构使用 OpenAI 兼容格式,支持任何端点,
307+
包括通过 LiteLLM 使用的本地 LLM、NVIDIA NIM 模型等。
308+
```
309+
310+
**4. 记录决策(无需 LLM)**
311+
312+
```bash
313+
$ ag report "认证模块需要重构"
314+
Logged report to .antigravity/memory/reports.md
315+
316+
$ ag log-decision "使用 PostgreSQL" "团队有丰富经验"
317+
Logged decision to .antigravity/decisions/log.md
318+
```
319+
320+
> 支持任何 OpenAI 兼容供应商:**NVIDIA****OpenAI****Ollama****vLLM****LM Studio****Groq** 等。
321+
322+
---
323+
272324
## 文档
273325

274326
| | |

README_ES.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,58 @@ Ver [docs Sandbox](docs/es/SANDBOX.md).
269269

270270
---
271271

272+
## Demo Real: NVIDIA API + Kimi K2.5
273+
274+
Probado end-to-end con [Moonshot Kimi K2.5](https://build.nvidia.com/moonshotai/kimi-k2-5) via el tier gratuito de NVIDIA. Cualquier endpoint compatible con OpenAI funciona igual.
275+
276+
**1. Configurar `.env`**
277+
278+
```bash
279+
OPENAI_BASE_URL=https://integrate.api.nvidia.com/v1
280+
OPENAI_API_KEY=nvapi-your-key-here
281+
OPENAI_MODEL=moonshotai/kimi-k2.5
282+
```
283+
284+
**2. Escanear tu proyecto**
285+
286+
```bash
287+
$ ag refresh --workspace .
288+
Updated .antigravity/conventions.md
289+
```
290+
291+
Salida generada por Kimi K2.5:
292+
```markdown
293+
# Project Conventions
294+
## Primary Language & Frameworks
295+
- **Language**: Python (5,135 files, 99%+ of codebase)
296+
- **Infrastructure**: Docker, Docker Compose
297+
- **CI/CD**: GitHub Actions
298+
...
299+
```
300+
301+
**3. Hacer preguntas**
302+
303+
```bash
304+
$ ag ask "¿Qué backends LLM soporta este proyecto?"
305+
Basado en el contexto, el proyecto soporta NVIDIA API con Kimi K2.5.
306+
La arquitectura usa formato compatible con OpenAI, soportando cualquier
307+
endpoint incluyendo LLMs locales via LiteLLM, modelos NVIDIA NIM, etc.
308+
```
309+
310+
**4. Registrar decisiones (sin LLM)**
311+
312+
```bash
313+
$ ag report "El módulo de auth necesita refactoring"
314+
Logged report to .antigravity/memory/reports.md
315+
316+
$ ag log-decision "Usar PostgreSQL" "El equipo tiene experiencia profunda"
317+
Logged decision to .antigravity/decisions/log.md
318+
```
319+
320+
> Funciona con cualquier proveedor compatible con OpenAI: **NVIDIA**, **OpenAI**, **Ollama**, **vLLM**, **LM Studio**, **Groq**, etc.
321+
322+
---
323+
272324
## Documentación
273325

274326
| | |

engine/antigravity_engine/hub/agents.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ def create_model(settings: "Settings") -> str:
1111
"""Resolve an LLM model identifier from settings.
1212
1313
Priority:
14-
1. GOOGLE_API_KEY → gemini/<model_name> via litellm
15-
2. OPENAI_API_KEY → <OPENAI_MODEL>
16-
3. OPENAI_BASE_URL → <OPENAI_MODEL> (local Ollama etc.)
17-
4. None → raise ValueError
14+
1. GOOGLE_API_KEY → litellm/gemini/<model_name>
15+
2. OPENAI_BASE_URL (any key) → litellm/openai/<model> (custom endpoint)
16+
3. OPENAI_API_KEY (no base) → <OPENAI_MODEL> (standard OpenAI)
17+
4. None → raise ValueError
18+
19+
When a custom OPENAI_BASE_URL is provided (e.g. NVIDIA, Ollama), the
20+
model is routed through litellm so that the Agent SDK can reach the
21+
non-standard endpoint. The function also exports OPENAI_API_BASE for
22+
litellm discovery.
1823
1924
Args:
2025
settings: Application settings.
@@ -25,15 +30,22 @@ def create_model(settings: "Settings") -> str:
2530
Raises:
2631
ValueError: When no LLM backend is configured.
2732
"""
33+
import os
34+
2835
if settings.GOOGLE_API_KEY:
2936
return f"litellm/gemini/{settings.GEMINI_MODEL_NAME}"
3037

31-
if settings.OPENAI_API_KEY:
32-
return settings.OPENAI_MODEL
33-
38+
# Custom endpoint (NVIDIA, Ollama, etc.) — route through litellm
3439
if settings.OPENAI_BASE_URL:
40+
os.environ.setdefault("OPENAI_API_BASE", settings.OPENAI_BASE_URL)
41+
if settings.OPENAI_API_KEY:
42+
os.environ.setdefault("OPENAI_API_KEY", settings.OPENAI_API_KEY)
3543
return f"litellm/openai/{settings.OPENAI_MODEL}"
3644

45+
# Standard OpenAI (no custom base URL)
46+
if settings.OPENAI_API_KEY:
47+
return settings.OPENAI_MODEL
48+
3749
raise ValueError(
3850
"No LLM configured. Set GOOGLE_API_KEY, OPENAI_API_KEY, "
3951
"or OPENAI_BASE_URL in .env"

engine/tests/test_create_model.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,32 @@ def test_google_key_returns_litellm_gemini():
3232
assert "gemini-2.0-flash-exp" in result
3333

3434

35-
def test_openai_key_returns_model_name():
35+
def test_openai_key_only_returns_model_name():
36+
"""Standard OpenAI (key but no custom base URL) returns raw model name."""
3637
settings = _make_settings(OPENAI_API_KEY="sk-test")
3738
result = create_model(settings)
3839
assert result == "gpt-4o-mini"
3940

4041

41-
def test_ollama_base_url_returns_litellm_openai():
42+
def test_base_url_routes_through_litellm():
43+
"""Custom base URL (Ollama, NVIDIA, etc.) routes through litellm."""
4244
settings = _make_settings(OPENAI_BASE_URL="http://localhost:11434/v1")
4345
result = create_model(settings)
4446
assert result.startswith("litellm/openai/")
4547
assert "gpt-4o-mini" in result
4648

4749

50+
def test_base_url_with_key_routes_through_litellm():
51+
"""Custom base URL + API key (NVIDIA) routes through litellm, not raw."""
52+
settings = _make_settings(
53+
OPENAI_BASE_URL="https://integrate.api.nvidia.com/v1",
54+
OPENAI_API_KEY="nvapi-test-key",
55+
OPENAI_MODEL="moonshotai/kimi-k2.5",
56+
)
57+
result = create_model(settings)
58+
assert result == "litellm/openai/moonshotai/kimi-k2.5"
59+
60+
4861
def test_no_config_raises_value_error():
4962
settings = _make_settings()
5063
with pytest.raises(ValueError, match="No LLM configured"):

0 commit comments

Comments
 (0)