icrim 93b0fd229c Release 0.2.0
Co-authored-by: xinchengxx <xinchengxx@deepseek.com>
Co-authored-by: zhu-he <hezhu@deepseek.com>
2026-10-20 00:21:22 +08:00

47 lines
1.5 KiB
Markdown

# server-rs
An Axum API example using the Rust components with mock inference. The
request's model name selects the DeepSeek V4 or V4.1 prompt encoding:
`DeepSeek-V4-Pro` and `deepseek-v4-pro` select V4, `DeepSeek-V4.1-Flash` and
`deepseek-flash` select V4.1, and conversion rejects any other name with a
`400` error. Images use OpenCV preprocessing.
## Usage
Install the
[Rust and OpenCV prerequisites](../docs/development.md#native-dependencies),
then run from the repository root:
```sh
cargo run -p server-rs --locked
```
The server listens on `127.0.0.1:7777`. Set `SERVER_ADDR` to change the address.
## API
- `POST /v1/chat/completions`
- `POST /v1/responses`
- `POST /v1/messages`
All three protocols support JSON for `stream=false` and SSE for `stream=true`.
For example, in a second terminal:
```sh
curl http://127.0.0.1:7777/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"deepseek-flash","messages":[{"role":"user","content":"Hello"}],"stream":false}'
```
The response contains the mock answer `Hello world!`. Set `"stream":true` and
add `-N` to curl to inspect SSE output. No API key or model weights are
required.
## Deployment scope
This example has no authentication and uses an image fetcher that does not
filter private network addresses. Keep it on loopback for local use; see the
[deployment considerations](../docs/development.md#example-servers) before
exposing it to other users. The Python example uses the same default port.