Skip to content
Back to skills

Api Serving

ASecurity

"Guides ChatGLM2-6B FastAPI and OpenAI-compatible serving, request

  • 247 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 8, 2026
developmentpythonfastapitestingapibackendsecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill api-serving --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Serving?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Serving
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-api-serving/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-api-serving)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-serving
description: "Guides ChatGLM2-6B FastAPI and OpenAI-compatible serving, request
  validation, conversation-history mapping, streaming SSE, and safe local
  deployment."
disable-model-invocation: true
metadata:
  disco-role: operating
license: NOASSERTION
---

# ChatGLM2-6B API Serving

Use this route for the repo's HTTP services, curl/OpenAI client integration,
SSE streaming, endpoint contracts, or service troubleshooting. Use
[`chat-and-demos`](../chat-and-demos/SKILL.md) for local UI/CLI generation and
[`ptuning`](../ptuning/SKILL.md) when the model is a prefix/full fine-tuned
checkpoint.

## Choose the endpoint

- **Simple API:** a FastAPI POST `/` accepting `prompt`, optional `history`,
  `max_length`, `top_p`, and `temperature`. It returns `response`, updated
  `history`, `status`, and a timestamp.
- **OpenAI-compatible API:** `GET /v1/models` plus
  `POST /v1/chat/completions`. Use this for clients that already speak the
  Chat Completions protocol. The repository supports normal JSON responses and
  Server-Sent Event streaming.

Read [`api-contracts.md`](references/api-contracts.md) before writing a client.
Read [`deployment.md`](references/deployment.md) before starting Uvicorn; the
service loads model weights once, keeps global `model`/`tokenizer` state, and
binds a listener. Run the bundled validators first:

```text
python sub-skills/api-serving/scripts/validate_api_payload.py --json '{"prompt":"你好","history":[]}'
python sub-skills/api-serving/scripts/validate_openai_messages.py --json '{"model":"chatglm2-6b","messages":[{"role":"user","content":"你好"}]}'
```

## Serve safely

1. Select a complete model directory or Hub id and a backend; the repo's
   launch path calls `.cuda()` and assumes model weights fit on one or more
   GPUs.
2. Install `fastapi`, `uvicorn`, and `sse-starlette` for the OpenAI streaming
   route in addition to the model runtime.
3. Bind to localhost while testing. Use one worker unless you deliberately
   duplicate model memory and have an external process policy.
4. Validate request roles/history before sending traffic. For streaming,
   parse JSON chunks until the final `finish_reason` chunk and `[DONE]`.
5. Treat CORS and `allow_origins=["*"]` as development defaults, not a
   production security policy. Add authentication, origin restrictions, rate
   limits, and timeouts outside this legacy sample.

The source route introspection is safe and confirms `/`, `/v1/models`, and
`/v1/chat/completions`; it does not prove that a model can load. Use
[`troubleshooting.md`](references/troubleshooting.md) for model, port, role,
SSE, and memory failures.

Files in this skill

  • SKILL.md2.6 KB
  • references/api-contracts.md2.2 KB
  • references/deployment.md2.1 KB
  • references/troubleshooting.md2 KB
  • scripts/openai_api_server.py6.7 KB
  • scripts/simple_api_server.py3.4 KB
  • scripts/validate_api_payload.py2.6 KB
  • scripts/validate_openai_messages.py3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.