Nscale (欧盟主权)
https://docs.nscale.com/docs/inference/chat
提示
我们支持所有 Nscale 模型,只需在发送 litellm 请求时将 model=nscale/<任意-Nscale-模型>
设置为前缀即可
属性 | 详情 |
---|---|
描述 | 一个总部位于欧洲、提供 LLM 和图像生成功能的,全栈人工智能云平台。 |
LiteLLM 上的提供商路由 | nscale/ |
支持的端点 | /chat/completions , /images/generations |
API 参考 | Nscale 文档 |
所需变量
环境变量
os.environ["NSCALE_API_KEY"] = "" # your Nscale API key
探索可用模型
探索我们完整的文本和多模态 AI 模型列表 — 所有模型均提供极具竞争力的价格:📚 完整模型列表
主要功能
- 欧盟主权:完全的数据主权并遵守欧洲法规
- 超低成本($0.01 / M tokens 起):文本和图像生成模型价格极具竞争力
- 生产级别:可靠的无服务器部署,完全隔离
- 无需设置:即时访问计算资源,无需基础设施管理
- 完全控制:您的数据保持私密和隔离
使用方法 - LiteLLM Python SDK
文本生成
Nscale 文本生成
from litellm import completion
import os
os.environ["NSCALE_API_KEY"] = "" # your Nscale API key
response = completion(
model="nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct",
messages=[{"role": "user", "content": "What is LiteLLM?"}]
)
print(response)
Nscale 文本生成 - 流式
from litellm import completion
import os
os.environ["NSCALE_API_KEY"] = "" # your Nscale API key
stream = completion(
model="nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct",
messages=[{"role": "user", "content": "What is LiteLLM?"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")
图像生成
Nscale 图像生成
from litellm import image_generation
import os
os.environ["NSCALE_API_KEY"] = "" # your Nscale API key
response = image_generation(
model="nscale/stabilityai/stable-diffusion-xl-base-1.0",
prompt="A beautiful sunset over mountains",
n=1,
size="1024x1024"
)
print(response)
使用方法 - LiteLLM 代理
将以下内容添加到您的 LiteLLM 代理配置文件中
config.yaml
model_list:
- model_name: nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct
litellm_params:
model: nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct
api_key: os.environ/NSCALE_API_KEY
- model_name: nscale/meta-llama/Llama-3.3-70B-Instruct
litellm_params:
model: nscale/meta-llama/Llama-3.3-70B-Instruct
api_key: os.environ/NSCALE_API_KEY
- model_name: nscale/stabilityai/stable-diffusion-xl-base-1.0
litellm_params:
model: nscale/stabilityai/stable-diffusion-xl-base-1.0
api_key: os.environ/NSCALE_API_KEY
启动您的 LiteLLM 代理服务器
启动 LiteLLM 代理
litellm --config config.yaml
# RUNNING on http://0.0.0.0:4000
- OpenAI SDK
- LiteLLM SDK
- cURL
通过代理使用 Nscale - 非流式
from openai import OpenAI
# Initialize client with your proxy URL
client = OpenAI(
base_url="http://localhost:4000", # Your proxy URL
api_key="your-proxy-api-key" # Your proxy API key
)
# Non-streaming response
response = client.chat.completions.create(
model="nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct",
messages=[{"role": "user", "content": "What is LiteLLM?"}]
)
print(response.choices[0].message.content)
通过代理使用 Nscale - LiteLLM SDK
import litellm
# Configure LiteLLM to use your proxy
response = litellm.completion(
model="litellm_proxy/nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct",
messages=[{"role": "user", "content": "What is LiteLLM?"}],
api_base="http://localhost:4000",
api_key="your-proxy-api-key"
)
print(response.choices[0].message.content)
通过代理使用 Nscale - cURL
curl http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-proxy-api-key" \
-d '{
"model": "nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct",
"messages": [{"role": "user", "content": "What is LiteLLM?"}]
}'
入门
- 在 console.nscale.com 创建账户
- 领取免费额度
- 在设置中创建 API 密钥
- 开始使用 LiteLLM 调用 API