¶ LangChain and SDK integration
Any SDK that supports a custom OpenAI-compatible Base URL can connect to AzYun.Com.
Copy
npm install @langchain/openai
export AZYUN_API_KEY="YOUR_API_KEY"
Copy
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
apiKey: process.env.AZYUN_API_KEY,
configuration: { baseURL: "https://www.azyun.com/v1" },
model: "MODEL_ID_FROM_CONSOLE",
});
Copy
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AZYUN_API_KEY,
baseURL: "https://www.azyun.com/v1",
defaultHeaders: { "User-Agent": "azyun.com-Node/1.0" },
});
const response = await client.chat.completions.create({
model: "MODEL_ID_FROM_CONSOLE",
messages: [{ role: "user", content: "Hello" }],
});
| Symptom | Check |
|---|---|
| SDK still calls official OpenAI | Use baseURL in JavaScript or base_url in Python and set it to https://www.azyun.com/v1. |
| Browser reports CORS | Do not expose the key in frontend code; call AzYun.Com through your own backend. |
| Tool calling fails | Verify plain chat first, then confirm the selected model and route support tools or function calling. |