Skip to content
Jents Academy
Connect your AI 3 min read

Route your own code through Jents

For anything you wrote that calls an LLM — a backend service, a chatbot, a RAG pipeline, a serverless function, a batch job, an embeddings call, or a one-off script. They all set up the same way: point your AI client at Jents.


How it works

Jents runs an OpenAI-compatible gateway. You change just two things in your code — the base URL and the API key — and every call routes through Jents for exact cost, tokens, and control, all attributed to this source. Nothing else in your code changes.

1. Create the source in Jents

  1. Capture AI source → "AI you build or run" → "Yes — I can point it at a URL."
  2. Name it, set an owner and team, and create it.
  3. Jents gives you a gateway URL. On the source's page, open the Keys tab and Provision to mint its key. Copy both.

2. Point your client at the gateway

Python (OpenAI SDK):

from openai import OpenAI

client = OpenAI(
    base_url="https://YOUR-GATEWAY-URL",   # from the setup step
    api_key="YOUR-AGENT-KEY",              # the key you provisioned
)

resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)

Node / TypeScript:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://YOUR-GATEWAY-URL",
  apiKey: process.env.JENTS_KEY,   // the key you provisioned
});

Using the Anthropic SDK? Set base_url (Python) / baseURL (JS) to your gateway URL the same way.

Store the key in an environment variable — don't hard-code it.

3. Run it and confirm

Make one call, then open the source's Keys tab — it flips to "Working ✓" once the first call lands, and the spend shows in Observability within seconds.


Running on a schedule (cron)?

Same setup — just make sure the base URL + key are set as environment variables in your cron job, CI, or scheduler, so every run routes through Jents.

Embeddings and other endpoints

Embeddings, chat completions, and responses all route the same way — set the base URL + key once on the client and every endpoint is covered.