Skip to main content

OpenAI Compatibility

GoingMerry provides a built-in OpenAI-compatible API gateway. You can use standard OpenAI SDK clients, LangChain modules, or web frontends by redirecting request traffic to your local GoingMerry daemon.

  • Base URL: http://localhost:11434/v1
  • API Key: Any dummy string value (e.g. merry or ignored).

Supported Endpoints

  • POST /v1/chat/completions -> Mapped directly to /api/chat
  • POST /v1/embeddings -> Mapped directly to /api/embeddings

Python Integration

Use the official openai Python package by modifying the client parameters:

from openai import OpenAI

client = OpenAI(
base_url="http://localhost:11434/v1",
api_key="merry", # Required but ignored by GoingMerry
)

response = client.chat.completions.create(
model="gemma4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the primary optimization in GoingMerry?"}
],
temperature=0.7,
stream=True
)

for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)

Node.js Integration

Modify the standard configuration using the Javascript/TypeScript library:

import OpenAI from 'openai';

const openai = new OpenAI({
baseURL: 'http://localhost:11434/v1',
apiKey: 'merry', // Required but ignored
});

async function main() {
const stream = await openai.chat.completions.create({
model: 'gemma4',
messages: [{ role: 'user', content: 'Explain branchless programming' }],
stream: true,
});

for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
}

main();

LangChain Setup

Redirect completion calls inside LangChain python:

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
model="gemma4",
openai_api_key="merry",
openai_api_base="http://localhost:11434/v1"
)

response = llm.invoke("Hello LangChain!")
print(response.content)

LiteLLM CLI Execution

Test routing using the LiteLLM proxy boundary:

litellm --model openai/gemma4 --api_base http://localhost:11434/v1