安装
配置兼容 OpenAI 的 LLM
在索引中使用
说明
- 对于第三方 OpenAI 兼容 API,请使用
OpenAILike。 - 请明确指定生成模型和嵌入模型 ID。不要假设 LlamaIndex 默认值会指向 Phaseo。
- 如果使用 Phaseo 嵌入,请使用 Phaseo 模型 ID 和相同的 Base URL 设置嵌入模型。
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
在 LlamaIndex RAG 工作流中使用 Phaseo。
pip install llama-index llama-index-llms-openai-like llama-index-embeddings-openai-like
import os
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
model="openai/gpt-5-nano",
api_key=os.environ["PHASEO_API_KEY"],
api_base="https://api.phaseo.app/v1",
is_chat_model=True,
)
response = llm.complete("Write one sentence about retrieval quality.")
print(response)
from llama_index.core import Settings
Settings.llm = llm
OpenAILike。