Guides
Use the OpenAI SDK
Point an existing OpenAI client at Deeplinq and stream a response.
Deeplinq implements the OpenAI chat-completions and models surfaces. Configure the SDK with the engine base URL and a Deeplinq credential. See the parameter compatibility matrix for which request fields are implemented, rejected, or silently tolerated.
TypeScript
import OpenAI from "openai"
const client = new OpenAI({
apiKey: process.env.DEEPLINQ_TOKEN,
baseURL: `${process.env.DEEPLINQ_BASE_URL}/v1`,
})
const stream = await client.chat.completions.create({
model: "auto",
stream: true,
messages: [{ role: "user", content: "Explain reciprocal rank fusion." }],
})
for await (const event of stream) {
process.stdout.write(event.choices[0]?.delta.content ?? "")
}Python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DEEPLINQ_TOKEN"],
base_url=f'{os.environ["DEEPLINQ_BASE_URL"]}/v1',
)
response = client.chat.completions.create(
model="auto",
messages=[
{
"role": "user",
"content": "Explain reciprocal rank fusion.",
}
],
)
print(response.choices[0].message.content)Tenant attribution
When you act for a person, use their end-user token. The user travels inside the token, so there is no header to set and nothing for an untrusted client value to reach:
const client = new OpenAI({
apiKey: await accessTokenFor(authenticatedUser), // that user's own token
baseURL: `${process.env.DEEPLINQ_BASE_URL}/v1`,
})Spend, per-user limits and resource ownership all follow the principal the token resolves to. A machine token carries no end user: its spend is organization-level, and user-owned endpoints refuse it.