这页是框架集成文档。原始 HTTP 端点说明请看
Chat Completions 或
Responses。
安装
代码示例
- Python
- Node.js
流式响应
函数调用
相关文档
OpenAI 概述
查看 Header、模型和原生路由
Chat Completions
查看
POST /v1/chat/completions 的端点说明开发工具总览
查看 PipeLLM 上的更多工具与框架集成
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
使用 LangChain 的 ChatOpenAI 接入 PipeLLM 的 OpenAI 兼容路由
pip install langchain-openai
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model='gpt-5',
api_key=os.getenv('PIPELLM_API_KEY'),
base_url='https://api.pipellm.ai/v1'
)
response = llm.invoke([
('user', 'Why is the sky blue?')
])
print(response.content)
import { ChatOpenAI } from '@langchain/openai';
const llm = new ChatOpenAI({
model: 'gpt-5',
apiKey: process.env.PIPELLM_API_KEY,
configuration: {
baseURL: 'https://api.pipellm.ai/v1'
}
});
const response = await llm.invoke([
{ role: 'user', content: 'Why is the sky blue?' }
]);
console.log(response.content);
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model='gpt-5',
api_key=os.getenv('PIPELLM_API_KEY'),
base_url='https://api.pipellm.ai/v1',
streaming=True
)
for chunk in llm.stream('Tell me a story'):
print(chunk.content, end='', flush=True)
import os
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
@tool
def get_weather(location: str) -> str:
"""获取指定地点的天气"""
return f"{location} 的天气:22°C,晴天"
llm = ChatOpenAI(
model='gpt-5',
api_key=os.getenv('PIPELLM_API_KEY'),
base_url='https://api.pipellm.ai/v1'
)
llm_with_tools = llm.bind_tools([get_weather])
response = llm_with_tools.invoke("东京现在天气怎么样?")
print(response.tool_calls)
POST /v1/chat/completions 的端点说明此页面对您有帮助吗?