快速入门

大约五分钟,向 ReadyServer LLM API 发出你的第一个请求。

请在你的 ReadyServer VPS 上运行这些命令

该 API 仅可通过 ReadyServer 的私有网络访问,因此在你自己的电脑上不会有响应。

开始之前

1. 确认可以访问该 API

列出当前提供的模型:

curl http://api.readyserver.ai/v1/models

你应该会收到类似这样的 JSON 响应(已精简):

{
  "object": "list",
  "data": [
    {
      "id": "qwen3.6-27b",
      "object": "model",
      "owned_by": "vllm",
      "max_model_len": 131072
    },
    {
      "id": "qwen3.8-27b",
      "object": "model",
      "owned_by": "vllm",
      "max_model_len": 262144
    },
    {
      "id": "qwen3-embedding-8b",
      "object": "model",
      "owned_by": "vllm",
      "max_model_len": 32768
    }
  ]
}

如果命令卡住或连接被拒绝,请查看故障排查。

2. 设置环境变量

OpenAI SDK 和许多其他工具都会读取这些变量,因此端点只需设置一次:

export OPENAI_BASE_URL="http://api.readyserver.ai/v1"
export OPENAI_API_KEY="not-needed"

无需 API 密钥。但 OpenAI SDK 在没有密钥时会拒绝启动,因此请填入任意非空的占位值。若希望退出登录后仍保留设置,请将这两行加入 ~/.bashrc。

3. 发送一次对话请求

curl

curl "$OPENAI_BASE_URL/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.6-27b",
    "messages": [
      {"role": "user", "content": "Explain what a VPS is in one sentence."}
    ],
    "max_tokens": 200
  }'

Python

# pip install openai
from openai import OpenAI

client = OpenAI()  # reads OPENAI_BASE_URL and OPENAI_API_KEY

response = client.chat.completions.create(
    model="qwen3.6-27b",
    messages=[{"role": "user", "content": "Explain what a VPS is in one sentence."}],
    max_tokens=200,
)
print(response.choices[0].message.content)

Node.js

// npm install openai, then save as hello.mjs and run: node hello.mjs
import OpenAI from "openai";

const client = new OpenAI(); // reads OPENAI_BASE_URL and OPENAI_API_KEY

const response = await client.chat.completions.create({
  model: "qwen3.6-27b",
  messages: [{ role: "user", content: "Explain what a VPS is in one sentence." }],
  max_tokens: 200,
});
console.log(response.choices[0].message.content);

4. 流式接收响应

流式传输会在 token 生成时即时发送,用户可以立即看到输出。它是聊天界面与长回答的最佳选择。

curl

curl -N "$OPENAI_BASE_URL/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.6-27b",
    "messages": [{"role": "user", "content": "Write a haiku about servers."}],
    "stream": true
  }'

Python

from openai import OpenAI

client = OpenAI()

stream = client.chat.completions.create(
    model="qwen3.6-27b",
    messages=[{"role": "user", "content": "Write a haiku about servers."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
print()

Node.js

import OpenAI from "openai";

const client = new OpenAI();

const stream = await client.chat.completions.create({
  model: "qwen3.6-27b",
  messages: [{ role: "user", content: "Write a haiku about servers." }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
process.stdout.write("\n");

搭配其他工具使用

大多数支持 OpenAI 兼容接口的工具——例如智能体框架、聊天界面与编程智能体——都提供 base URL 或 API base 设置。请在你的 VPS 上运行该工具,并设置:

设置项值
Base URLhttp://api.readyserver.ai/v1
模型qwen3.6-27b 或 qwen3.8-27b
API 密钥任意占位值,例如 not-needed

后续步骤