- Python
- NodeJS
Synchronous Usage
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
]
)
print(completion.choices[0].message)
Asynchronous Usage
import asyncio
from openai import AsyncOpenAI
import dokumetry
client = AsyncOpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
async def main() -> None:
chat_completion = await client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
model="gpt-3.5-turbo",
)
asyncio.run(main())
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
async function main() {
const completion = await openai.chat.completions.create({
messages: [
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
model: "gpt-3.5-turbo",
});
console.log(completion.choices[0]);
}
main();

