Use the OpenAI libraries
Point any OpenAI SDK at TengoChat by changing the base URL. Streaming included.
The chat completions endpoint follows the OpenAI format, so the official libraries, and the tools built on them, work as they are. Change two things: the base URL and the key.
Python
# pip install openai
import os
from openai import OpenAI
client = OpenAI(
base_url="https://tengochat.com/api/v1",
api_key=os.environ["TENGOCHAT_API_KEY"],
)
reply = client.chat.completions.create(
model="tengo-1",
messages=[
{"role": "system", "content": "You are a friendly support agent."},
{"role": "user", "content": "How do I reset my password?"},
],
)
print(reply.choices[0].message.content)Node and TypeScript
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://tengochat.com/api/v1",
apiKey: process.env.TENGOCHAT_API_KEY,
});
const stream = await client.chat.completions.create({
model: "tengo-1",
stream: true,
messages: [{ role: "user", content: "Write a limerick about TypeScript" }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}LangChain, Vercel AI SDK and others
Anything that lets you set an OpenAI base URL works the same way:
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="tengo-1", base_url="https://tengochat.com/api/v1", api_key=os.environ["TENGOCHAT_API_KEY"])
print(llm.invoke("Explain vectors simply").content)import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const tengo = createOpenAI({ baseURL: "https://tengochat.com/api/v1", apiKey: process.env.TENGOCHAT_API_KEY });
const { text } = await generateText({ model: tengo.chat("tengo-1"), prompt: "Explain vectors simply" });Function calling through tools runs on agents, where tools run on our side with your connectors: see Call your agent from your app. Image inputs are not taken yet.
Models
Use tengo-1 for most things, tengo-1-mini for speed and volume, and tengo-1-pro when it should think longer. GET /models lists them with their prices.