# "OpenAI-compatible servers": one client for a local Ollama, one for# Azure OpenAI. Run with Ollama (or fake.j) on 127.0.0.1:11434:# jennifer run local.j# AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY, when set, send the same# question to an Azure deployment as well.use io; use json; use os;
import"@deckyard/openai/"as openai;
def local asopenai.Client initopenai.withBaseUrl(
openai.client(""), "http://127.0.0.1:11434/v1");
def req asjson.Value initopenai.addUserText(
openai.newRequest("qwen3:4b"), "Why is the sky blue?");
io.printf("local: %s\n", openai.text(openai.chat($local, $req)));
# plain http to another host is refused unless withPlainHttpdef remote asopenai.Client initopenai.withBaseUrl(
openai.client(""), "http://192.0.2.10:11434/v1");
try {
openai.chat($remote, $req);
} catch (e) {
io.printf("remote: %s (%s)\n", $e.kind, $e.message);
}
if (os.hasEnv("AZURE_OPENAI_ENDPOINT")) {
def endpoint asstringinitos.getEnv("AZURE_OPENAI_ENDPOINT");
def azureKey asstringinitos.getEnv("AZURE_OPENAI_KEY");
def az asopenai.Client initopenai.azure($endpoint, $azureKey);
io.printf("azure: %s\n", openai.text(openai.chat($az, $req)));
}