SDK
LangChain and SDK integration
Any SDK that supports a custom OpenAI-compatible Base URL can connect to 678API.
Install and configure
npm install @langchain/openai
export API678_API_KEY="YOUR_API_KEY"LangChain JS
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
apiKey: process.env.API678_API_KEY,
configuration: { baseURL: "https://www.678api.com/v1" },
model: "MODEL_ID_FROM_CONSOLE",
});OpenAI SDK
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.API678_API_KEY,
baseURL: "https://www.678api.com/v1",
defaultHeaders: { "User-Agent": "678API-Node/1.0" },
});
const response = await client.chat.completions.create({
model: "MODEL_ID_FROM_CONSOLE",
messages: [{ role: "user", content: "Hello" }],
});Production checklist
- Use the exact model ID shown in the 678API console.
- Create separate keys for development, staging, and production; set request timeouts and bounded retries.
- Log timing, model, and error codes without logging full keys or sensitive user content.
- Keep keys on the server. Never bundle a real key into browser code, desktop installers, or public repositories.
Common issues
| Symptom | Check |
|---|---|
| SDK still calls official OpenAI | Use baseURL in JavaScript or base_url in Python and set it to https://www.678api.com/v1. |
| Browser reports CORS | Do not expose the key in frontend code; call 678API through your own backend. |
| Tool calling fails | Verify plain chat first, then confirm the selected model and route support tools or function calling. |