Skip to main content

Quickstart

Djelia speaks the OpenAI protocol, so you use the OpenAI SDK for your language. There is no Djelia library to install.

1. Get a key

Create one in the Djelia Console and put it in your environment:

export DJELIA_API_KEY="your-api-key"

2. Install the OpenAI SDK

pip install openai

3. Make Bambara speech

import os
from openai import OpenAI

client = OpenAI(
api_key=os.environ["DJELIA_API_KEY"],
base_url="https://api.djelia.cloud/openai/v1",
)

speech = client.audio.speech.create(
model="jifili-1",
input="Aw ni ce, i ka kene wa?",
voice="moussa",
)
speech.write_to_file("hello.mp3")

You now have an mp3 of Bambara speech. Aw ni ce, i ka kene wa? is "Hello, how are you?"

4. Read it back

transcript = client.audio.transcriptions.create(
file=open("hello.mp3", "rb"),
model="sunjata-1",
)
print(transcript.text)
Aw ni ce, i ka kɛnɛ wa?

5. Translate text

Text translation is addressed as a chat model. The language pair is a Djelia extension, because a chat request has nowhere else to carry it.

completion = client.chat.completions.create(
model="banjugu-1",
messages=[{"role": "user", "content": "Bonjour, comment allez-vous ?"}],
extra_body={"djelia": {"source_language": "fra_Latn", "target_language": "bam_Latn"}},
)
print(completion.choices[0].message.content)
Nbá, í ni sɔ̀gɔmà ?

Next

  • Djelia extensions for prompt-steerable voices, telephony formats and the language pair
  • Models for what each model is good at, and the OpenAI aliases
  • API reference for every endpoint and field
  • Errors for the envelope and what each status means