DeepSeek
Access DeepSeek models through LangDB’s API using OpenAI SDK, enabling fast, reliable AI performance across platforms.
LangDB provides first class support for DeepSeek AI’s models.
You can use OpenAI SDK to run the deepseek models.
# Please install OpenAI SDK first: `pip3 install openai`
from openai import OpenAI
api_base = "https://api.us-east-1.langdb.ai" # LangDB API base URL
api_key = "xxxxx" # Replace with your LangDB token
default_headers = {"x-project-id": "xxxxx"} # LangDB Project ID
client = OpenAI(
base_url=api_base,
api_key=api_key,
)
response = client.chat.completions.create(
model="deepseek-reasoner",
messages=[
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello"}
],
stream=False
)
print(response.choices[0].message.content)// Please install OpenAI SDK first: `npm install openai`
import OpenAI from "openai";
const apiBase = "https://api.us-east-1.langdb.ai"; // LangDB API base URL
const apiKey = "LANGDB_API_KEY"; // Replace with your LangDB token
const defaultHeaders = { "x-project-id": "xxxx" }; // LangDB Project ID
const client = new OpenAI({
baseURL: apiBase,
apiKey: apiKey,
});
async function main() {
const completion = await client.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }, {"role": "user", "content": "Hello"}],
model: "deepseek-reasoner",
}, { headers: defaultHeaders });
console.log(completion.choices[0].message.content);
}
main();curl "https://api.us-east-1.langdb.ai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LANGDB_API_KEY" \
-X "X-Project-Id: $Project_ID" \
-d '{
"model": "deepseek-reasoner",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
]
}'Was this helpful?