Skip to main content

Applications

Its easy to integrate applications that leverage LLMs with Javelin. We have made it easy to seamlessly connect your applications to route all LLM traffic through Javelin with 3 lines of code change.

Leveraging the Javelin Platform

Rather than having your LLM Applications (like Co-Pilot apps etc.,) individually & directly point to the LLM Vendor & Model (like OpenAI, Gemini etc.,), configure the provider/model endpoint to be your Javelin endpoint. This ensures that all applications that leverage AI Models will route their requests through the gateway. Javelin supports all the latest models and providers, so you don't have to make any changes to your application or how requests to models are sent.

See Python SDK for details on how you can easily embed this within your AI Apps.

See Javelin Configuration section, for details on how to setup routes on the gateway to different models and providers.

As cloud computing advances, those involved with Kubernetes should pay attention to the evolving Gateway API. Check out Gateway API for detailed insights into its concepts and explore various Use Cases. We are building Javelin to provide a robust framework for managing these interactions seamlessly for new AI-driven applications or integrating AI capabilities into existing solutions.

Querying an LLM

Javelin may send a request to one or more models based on the configured policies and route configurations and return back a response.

REST API

curl -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: $JAVELIN_API_KEY" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"messages": [
{
"role": "system",
"content": "Hello, you are a helpful scientific assistant."
},
{
"role": "user",
"content": "What is the chemical composition of sugar?"
}
],
"temperature": 0.8
}' \
"https://api.javelin.live/v1/query/{routename}"

Python

pip install javelin-sdk
from javelin_sdk import (
JavelinClient,
Route
)

import os

javelin_api_key = os.getenv('JAVELIN_API_KEY')
llm_api_key = os.getenv("OPENAI_API_KEY")

# create javelin client
client = JavelinClient(javelin_api_key=javelin_api_key,
llm_api_key=llm_api_key)

# route name to get is {routename} e.g., sampleroute1
query_data = {
"messages": [
{
"role": "system",
"content": "Hello, you are a helpful scientific assistant."
},
{
"role": "user",
"content": "What is the chemical composition of sugar?"
}
],
"temperature": 0.8,
}

# now query the route, for async use `await client.aquery_route("sampleroute1", query_data)`
response = client.query_route("sampleroute1", query_data)
print(response.model_dump_json(indent=2))

JavaScript/TypeScript

npm install openai
import OpenAI from "openai";

const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: "https://api.javelin.live/v1/query",
defaultHeaders: {
"x-api-key": `${process.env.JAVELIN_API_KEY}`,
"x-javelin-route": "sample_route1",
},
});

async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }],
model: "gpt-3.5-turbo",
});

console.log(completion.choices[0]);
}

main();