基础 URL 和认证
使用 https://api.hereticllmmodels.com/v1 作为您的基础 URL。在 Authorization: Bearer <key> 。通过 Google 或电子邮件登录生成密钥。Token 按使用的 token 数量收费。
首次请求
向 /v1/chat/completions. 使用模型 uncensored. 设置 max_tokens to 16,000. Errors are free. Credit never expires. No monthly fees apply.
curl https://api.hereticllmmodels.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "calculate the derivative of 3x squared plus 5x"}]
}'
Python SDK
安装官方 OpenAI 包。设置 base_url 指向我们的端点。使用 model="uncensored". 流式传输通过 SSE 实现。支持工具调用。提供 JSON 模式。Temperature 参数调节随机性。Top_p 控制核采样。停止序列可终止生成。Seed 确保可复现性。存在惩罚和频率惩罚可减少重复。错误不会消耗额度。
from openai import OpenAI
client = OpenAI(base_url="https://api.hereticllmmodels.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
Node SDK
配置 Node.js 客户端。正确设置 base URL。使用 uncensored 模型 ID。轻松流式传输响应。传递工具以进行函数调用。强制执行 JSON 输出模式。调整 temperature 和 top_p。设置 stop sequences。固定 seed 以确保一致性。应用惩罚修饰符。无错误。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.hereticllmmodels.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);
流式传输与 SSE
设置 stream: true 在请求中。接收服务器发送事件(SSE)。按顺序解析数据块。Token 计数出现在最后一个数据块中。此方法显著降低了感知延迟。它允许实时显示生成的文本。缓冲管理由你负责。流中仍可能发生错误。优雅地处理断开连接。
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
限制和错误
上下文窗口为 100,000 token。最大输出为 16,000 token。每分钟限制为 300 次请求。每个密钥允许 8 个并发请求。最大主体大小为 8 MB。使用 401 表示无效密钥。使用 402 表示信用不足。使用 429 表示速率限制。
常见问题
异端 LLM 模型的上下文限制是多少?
上下文窗口支持 100,000 token。这包括你的输入提示词和模型的输出。每次请求最多可生成 16,000 个 token。
如何处理错误和计费?
错误和拒绝均免费。您只需为成功生成且返回的令牌付费。余额永不过期,无需订阅。可使用 402 代码查询余额状态。
有哪些可用的身份验证方法?
使用 Google 或邮箱注册。每个账户生成一个 API 密钥。通过 Authorization 头部传递。注册无需电话号码。
保护你的 API 密钥
注册,获取密钥,更新端点。只需最少的配置。