> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yelinai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain 配置指南

> 让 LangChain 指向 YeLin AI 的 OpenAI 兼容接口。

<Info>
  你可以把 LangChain 当作 OpenAI 来用。
  你只需要设置 base URL 与 **API key**。
</Info>

## 你先准备什么

1. 你在 **Console** 创建 **API key**。
2. 你准备好 base URL：`https://api.yelinai.com/v1`

## Python 示例

```python theme={"system"}
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["YELIN_API_KEY"],
    base_url="https://api.yelinai.com/v1",
)

resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "用一句话解释 RAG"}],
)

print(resp.choices[0].message.content)
```

<Tip>
  你可以先用最小示例跑通，再把 client 接到 LangChain 的封装里。
</Tip>

<CardGroup cols={2}>
  <Card title="对话补全" icon="message-circle" href="/api-reference/chat-completions">
    查看端点与参数。
  </Card>

  <Card title="模型列表" icon="list" href="/api-reference/models">
    获取模型 id。
  </Card>
</CardGroup>
