Spaces:
Running
Running
| title: Code 1B Chat API | |
| emoji: 💻 | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: docker | |
| pinned: false | |
| license: apache-2.0 | |
| # code-1b-chat-v2 — Inference API | |
| OpenAI-compatible REST API for the code-1b-chat-v2 model. | |
| Built with FastAPI + llama-cpp-python. Runs on CPU. | |
| ## Endpoints | |
| | Method | Path | Description | | |
| |--------|------|-------------| | |
| | GET | `/health` | Health check | | |
| | GET | `/v1/models` | List available models | | |
| | POST | `/v1/chat/completions` | Chat (OpenAI-compatible) | | |
| ## Example | |
| ```python | |
| import requests | |
| resp = requests.post( | |
| "https://rovdetection-code-1b-chat-space.hf.space/v1/chat/completions", | |
| json={ | |
| "model": "code-1b-chat-v2", | |
| "messages": [{"role": "user", "content": "Write a Python fibonacci function."}], | |
| "max_tokens": 200, | |
| "temperature": 0.7, | |
| } | |
| ) | |
| print(resp.json()["choices"][0]["message"]["content"]) | |
| ``` | |
| ## Streaming | |
| Add `"stream": true` to the request body for SSE streaming. | |