muna.beta.openai, with the same interface as the
official OpenAI client.
You can easily compile your own custom models to be compatible with Munaβs OpenAI client.
See the guide.
Creating Chat Completions
Muna supports running large language models via our clientβsopenai.chat.completions.create API:
import { Muna } from "muna"
// π₯ Create a Muna client
const openai = new Muna().beta.openai;
// π₯ Create a chat completion
const completion = await openai.chat.completions.create({
model: "@google/gemma-3-270m",
messages: [{ role: "user", content: "What is life?" }]
});
// π Print the result
console.log(completion.choices[0]);
from muna import Muna
# π₯ Create a Muna client
openai = Muna().beta.openai
# π₯ Create a chat completion
completion = openai.chat.completions.create(
model="@google/gemma-3-270m",
messages=[{ "role": "user", "content": "What is life?" }]
)
# π Print the result
print(completion.choices[0].message)
using Muna;
using Muna.Beta.OpenAI;
using static Muna.Beta.OpenAI.ChatMessage;
// π₯ Create a Muna client
var openai = MunaUnity.Create().Beta.OpenAI;
// π₯ Create a chat completion
var completion = await openai.Chat.Completions.Create(
model: "@google/gemma-3-270m",
messages: new[] {
new ChatMessage { Role = "user", Content = "What is life?" }
}
);
// π Print the result
Debug.Log(completion.Choices[0].Message);
Streaming Completions
Our OpenAI client also supports creating streaming completions:import { Muna } from "muna"
// π₯ Create a Muna client
const openai = new Muna().beta.openai;
// π₯ Stream a chat completion
const stream = await openai.chat.completions.create({
model: "@google/gemma-3-270m",
messages: [{ role: "user", content: "What is life?" }],
stream: true
});
// π Use completion chunks
for await (const chunk of stream)
...
from muna import Muna
# π₯ Create a Muna client
openai = Muna().beta.openai
# π₯ Stream a chat completion
stream = openai.chat.completions.create(
model="@google/gemma-3-270m",
messages=[{ "role": "user", "content": "What is life?" }],
stream=True
)
# π Use completion chunks
for chunk in stream:
...
using Muna;
using Muna.Beta.OpenAI;
using static Muna.Beta.OpenAI.ChatMessage;
// π₯ Create a Muna client
var openai = MunaUnity.Create().Beta.OpenAI;
// π₯ Stream a chat completion
var stream = openai.Chat.Completions.Stream(
model: "@google/gemma-3-270m",
messages: new[] {
new ChatMessage { Role = "user", Content = "What is life?" }
},
);
// π Use completion chunks
await foreach (var chunk in stream)
...
Creating Embeddings
Muna supports running text embedding models via our clientβsopenai.embeddings.create API:
import { Muna } from "muna"
// π₯ Create a Muna client
const openai = new Muna().beta.openai;
// π₯ Create a text embedding
const embedding = await openai.embeddings.create({
model: "@nomic/nomic-embed-text-v1.5",
input: "What is the capital of France?"
});
// π Use the embedding
console.log(embedding.data[0].embedding);
from muna import Muna
# π₯ Create a Muna client
openai = Muna().beta.openai
# π₯ Create a text embedding
embedding = openai.embeddings.create(
model="@nomic/nomic-embed-text-v1.5",
input="What is the capital of France?"
)
# π Use the embedding
print(embedding.data[0].embedding)
using Muna;
// π₯ Create a Muna client
var openai = MunaUnity.Create().Beta.OpenAI;
// π₯ Create a text embedding
var embedding = await openai.Embeddings.Create(
model: "@nomic/nomic-embed-text-v1.5",
input: "What is the capital of France?"
);
// π Use the embedding
Debug.Log(embedding.data[0].Floats);
Creating Speech
Muna supports running text-to-speech models via our clientβsopenai.audio.speech.create API:
import { Muna } from "muna"
// π₯ Create a Muna client
const openai = new Muna().beta.openai;
// π₯ Create speech
const response = await openai.audio.speech.create({
model: "@hexgrad/kokoro-tts",
input: "What a time to be alive",
voice: "af_jessica"
});
// π Use the speech
console.log(response);
from muna import Muna
# π₯ Create a Muna client
openai = Muna().beta.openai
# π₯ Create speech
response = openai.audio.speech.create(
model="@hexgrad/kokoro-tts",
input="What a time to be alive",
voice="af_jessica"
)
# π Use the speech
print(response)
Creating Transcriptions
Muna supports using speech-to-text models via our clientβsopenai.audio.transcriptions.create API:
import { Muna } from "muna"
// π₯ Create a Muna client
const openai = new Muna().beta.openai;
// π₯ Create transcription
const transcription = await openai.audio.transcriptions.create({
model: "@moonshine/moonshine-base",
file: audioFile
});
// π Use the transcribed text
console.log(transcription.text);
from muna import Muna
# π₯ Create a Muna client
openai = Muna().beta.openai
# π₯ Create transcription
transcription = openai.audio.transcriptions.create(
model="@moonshine/moonshine-base",
file=audio_file
)
# π Use the transcribed text
print(transcription.text)