Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Access FireworksAI models through LangDB’s API using OpenAI SDK
LangDB provides first class support for FireworksAI opensource hosted models.
You can use OpenAI SDK to run the xAI models.
from openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions
import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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"
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": "fireworksai/deepseek-r1",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
}'Access Anthropic models through LangDB’s API using OpenAI SDK
LangDB provides first class support for Anthropic models.
You can use OpenAI SDK to run the Anthropic 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
// 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 =
Connect LangDB to CrewAI using OpenAI-compatible setup to enhance LLM workflows with full tracing and streamlined monitoring.
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": "claude-3-5-sonnet-20240620",
"messages": [
{
"role": "system",
"content": "You are helpful assistant",
},
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
]
}'import { generateText } from 'ai';
import { createLangDB } from '@langdb/vercel-provider';
const langdb = createLangDB({
apiKey: process.env.LANGDB_API_KEY,
projectId: 'your-project-id',
});
export async function generateTextExample() {
const { text } = await generateText({
model: langdb('openai/gpt-4o-mini'),
prompt: 'Write a Python function that sorts a list:',
});
console.log(text);
}from crewai import LLM
project_id = "xxxx" ## LangDB Project ID
default_headers = {"x-project-id": project_id}
os.environ["OPENAI_API_KEY"] = (
"xxxx" ## LangDB API Key
)
llm_writer = LLM(model="gpt-4o-mini",
base_url=api_base,
extra_headers=default_headers)
# Your CrewAi code hereCheck out full examples here.
pip install crewaiUse LangDB with Mem0 to store memories, embed text, and streamline LLM interactions across scalable applications.
LangDB seemlessly integrate with Mem0.
Check out the Mem0 documentation for more information.
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
// 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 =
Connect LangDB to LangChain using OpenAI-compatible setup to enhance LLM workflows with full tracing and streamlined monitoring.
Access Amazon Bedrock models through LangDB’s API using OpenAI SDK
LangDB provides first class support for Bedrock models.
You can use to run the Bedrock models.
Connect LangDB seamlessly using the OpenAI Client SDK for Python, Node.js, or cURL with minimal code changes.
LangDB seamlessly integrate with OpenAI Client.
Install OpenAI Client SDK
Access TogetherAI models through LangDB’s API using OpenAI SDK
LangDB provides first class support for TogetherAI opensource hosted models.
You can use to run the xAI models.
Integrate Smithery's EXA MCP server into LangDB to enhance AI workflows with real-time, tool-driven interactions via WebSocket.
LangDB supports MCP servers provided by .
This particular example is for .
Access xAI models through LangDB’s API using OpenAI SDK
LangDB provides first class support for xAI models.
You can use to run the xAI models.
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."
}
]
}'from mem0 import Memory
from dotenv import load_dotenv
load_dotenv()
import os
langdb_api_key = os.getenv("LANGDB_API_KEY")
langdb_project_id = os.getenv("LANGDB_PROJECT_ID")
base_url = f"https://api.us-east-1.langdb.ai/{langdb_project_id}/v1"
config = {
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o",
"temperature": 0.0,
"api_key": langdb_api_key,
"openai_base_url": base_url,
},
},
"embedder": {
"provider": "openai",
"config": {
"model": "text-embedding-ada-002",
"api_key": langdb_api_key,
"openai_base_url": base_url,
},
}
}
m = Memory.from_config(config_dict=config)
result = m.add(
"I like to take long walks on weekends.",
user_id="alice",
metadata={"category": "hobbies"},
)
print(result)import os
from llama_index.llms import openai
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.core import Settings
from llama_index.llms.openai import OpenAI
Settings.llm = OpenAI(
base_url=os.getenv("OPENAI_API_BASE"),
api_key=os.getenv("OPENAI_API_KEY"),
model="gpt-4o-mini"
)
documents = SimpleDirectoryReader("data").load_data()
## Rest of your LlamaIndexfrom langchain_openai import ChatOpenAI
api_base = "https://api.us-east-1.langdb.ai"
api_key = "xxxx" # LangDB API Key
default_headers = {
"x-project-id": "xxxxx", ### LangDB Project ID
}
llm = ChatOpenAI(
model_name='gpt-4o' ,
temperature=0.3,
openai_api_base=api_base,
default_headers=default_headers,
disable_streaming=True )
# Your LangChain Code hereCheck out full examples in the samples.
pip install langchain langchain-openaifrom openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions.create(
model="bedrock/command-r-v1:0", # Use the model
messages=[{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}],
extra_headers={"x-project-id": "xxxxx"} # LangDB Project ID
)import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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,
});
const response = await client.chat.completions.create({
model: "bedrock/command-r-v1:0", // Use the model
messages: [{"role": "user","content": "What are the earnings of Apple in 2022?"}],
}, { headers: defaultHeaders });
// Rest of Your Codefrom openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions.create(
model="togetherai/DeepSeek-V3", # Use the model
messages=[{"role": "user", "content": "Hello!"}],
extra_headers={"x-project-id": "xxxxx"} # LangDB Project ID
)import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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,
});
const response = await client.chat.completions.create({
model: "togetherai/DeepSeek-V3", // Use the model
messages: [{"role": "user","content": "What are the earnings of Apple in 2022?"}],
}, { headers: defaultHeaders });
// Rest of Your Code\from openai import OpenAI
from dotenv import load_dotenv
import os
import base64
import json
from urllib.parse import quote
load_dotenv()
def urlEncode(data_dict):
"""Convert dictionary to base64 and then URL encode it"""
return quote(base64.b64encode(json.dumps(data_dict).encode()).decode())
config = {
"exaApiKey": os.getenv("EXA_API_KEY")
}
config_str = urlEncode(config)
web_socket_url = "wss://your-mcp-server.com/ws"
extra_body = {
"mcp_servers": [
{
"server_url": f"{web_socket_url}?config={config_str}",
"type": "ws"
}
]
}
client = OpenAI(
api_key=os.getenv("LANGDB_API_KEY"),
base_url=os.getenv("LANGDB_API_URL")
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "what is langdb?"}],
extra_body = extra_body
)
print(response)from openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions.create(
model="xai/grok-2", # Use the model
messages=[{"role": "user", "content": "Hello!"}],
extra_headers={"x-project-id": "xxxxx"} # LangDB Project ID
)import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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,
});
const response = await client.chat.completions.create({
model: "xai/grok-2", // Use the model
messages: [{"role": "user","content": "What are the earnings of Apple in 2022?"}],
}, { headers: defaultHeaders });
// Rest of Your Code\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": "bedrock/command-r-v1:0",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
}'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": "togetherai/DeepSeek-V3",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
}'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": "xai/grok-2",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions
import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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"
pip install openainpm install openaiVercel AI
Integration with Vercel AI SDK
LangChain
Integration with LangChain
CrewAI
Integration with CrewAI
LlamaIndex
Integration with LlamaIndex
Supabase
Integration with Supabase
mem0
Integration with Mem0

Connect LangDB to LangChain using OpenAI-compatible setup to generate embeddings and store them in Supabase for efficient data retrieval.
Access OpenRouter models through LangDB’s API using OpenAI SDK
LangDB provides first class support for OpenRouter models.
You can use to run the xAI models.
Access Gemini models through LangDB’s API using OpenAI SDK
LangDB provides first class support for Gemini models.
You can use to run the Gemini models.
Access DeepInfra models through LangDB’s API using OpenAI SDK
LangDB provides first class support for DeepInfra opensource hosted models.
You can use to run the xAI models.
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": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
"temperature": 0.8
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions.create(
model="openrouter/aion-1.0-mini", # Use the model
messages=[{"role": "user", "content": "Hello!"}],
extra_headers={"x-project-id": "xxxxx"} # LangDB Project ID
)import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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,
});
const response = await client.chat.completions.create({
model: "openrouter/aion-1.0-mini", // Use the model
messages: [{"role": "user","content": "What are the earnings of Apple in 2022?"}],
}, { headers: defaultHeaders });
// Rest of Your Code\# 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="gemini/gemini-1.5-flash-8b",
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: "gemini/gemini-1.5-flash-8b",
}, { headers: defaultHeaders });
console.log(completion.choices[0].message.content);
}
main();from openai import OpenAI
client = OpenAI(
base_url="https://api.us-east-1.langdb.ai" # LangDB API base URL,
api_key=api_key, # Replace with your LangDB token
)
# Make the API call to LangDB's Completions API
response = client.chat.completions.create(
model="deepinfra/phi-4", # Use the model
messages=[{"role": "user", "content": "Hello!"}],
extra_headers={"x-project-id": "xxxxx"} # LangDB Project ID
)import { OpenAI } from 'openai'; // Assuming you're using the OpenAI Node.js SDK
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,
});
const response = await client.chat.completions.create({
model: "deepinfra/phi-4", // Use the model
messages: [{"role": "user","content": "What are the earnings of Apple in 2022?"}],
}, { headers: defaultHeaders });
// Rest of Your Code\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": "openrouter/aion-1.0-mini",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
}'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": "gemini/gemini-1.5-flash-8b",
"messages": [
{
"role": "system",
"content": "You are helpful assistant",
},
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
]
}'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": "deepinfra/phi-4",
"messages": [
{
"role": "user",
"content": "Write a haiku about recursion in programming."
}
],
}'# # Store in Supabase
result = supabase.table('embeddings').insert({
"content": text,
"embedding": embedding
}).execute()create extension vector;create table embeddings (
id bigserial primary key,
content text,
embedding vector(1536)
);pip install openai python-dotenv supabasefrom openai import OpenAI
from dotenv import load_dotenv
from supabase import create_client, Client
import os
load_dotenv()
api_key = os.getenv("LANGDB_API_KEY")
project_id = os.getenv("LANGDB_PROJECT_ID")
base_url = f"https://api.us-east-1.langdb.ai/{project_id}/v1"
client = OpenAI(
base_url=base_url,
api_key=api_key,
)
text = "Hello LangDB"
response = client.embeddings.create(
model="text-embedding-ada-002",
input=text,
)
embedding = response.data[0].embedding














