File size: 920 Bytes
61bb677
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
import threading
from uvicorn import Server, Config
from httpx import Client
import time
from free_claude_code.runtime.bootstrap import build_asgi_app
from free_claude_code.config.admin.values import get_admin_settings

def run_server():
    settings = get_admin_settings()
    app = build_asgi_app(settings)
    config = Config(app, host="127.0.0.1", port=7862, log_level="error")
    server = Server(config)
    server.run()

t = threading.Thread(target=run_server, daemon=True)
t.start()

time.sleep(3)
try:
    with Client() as client:
        res = client.post("http://127.0.0.1:7862/v1/messages", json={
            "model": "nvidia/nemotron",
            "messages": [{"role": "user", "content": "hi"}],
            "max_tokens": 10
        }, headers={"Authorization": "Bearer TEST"})
        print(res.status_code)
        print(res.text)
except Exception as e:
    print(f"Request failed: {e}")