Skip to main content

Bijak Cloud 2.0 is here. Explore features

Quickstarts

Python SDK quickstart - Bijak Cloud Docs

Install the Bijak Cloud Python SDK, authenticate, and run your first RAG-grounded query.

Prerequisites

  • Python 3.10 or later
  • A Bijak Cloud API key (create one in the dashboard under Settings → API keys)

Install the SDK

pip install bijakcloud

The SDK ships with type hints and works with CPython 3.10+.

Authenticate

Export your API key as an environment variable:

export BIJAK_API_KEY=sk-bijak-your-key-here
export BIJAK_REGION=my-cyberjaya

The client constructor reads BIJAK_API_KEY from the environment by default. You can also pass it explicitly:

from bijakcloud import BijakClient

client = BijakClient(api_key="sk-bijak-your-key-here", region="my-cyberjaya")

Run an inference call

response = client.inference.chat(
    model="bijak-merlion-13b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is PDPA in one sentence?"},
    ],
    temperature=0.2,
)

print(response.choices[0].message.content)

Run a RAG query

RAG Studio lets you ground completions in your own documents. First upload a corpus:

corpus = client.rag.corpus.create(name="hr-handbook")

client.rag.documents.upload(
    corpus_id=corpus.id,
    file_path="./handbook.pdf",
)

client.rag.corpus.wait_until_ready(corpus.id)

Then query it:

answer = client.rag.query(
    corpus_id=corpus.id,
    question="How many days of annual leave do employees get?",
)

print(answer.response)
print(answer.citations)

Every chunk used to answer the question is cited, so you can audit exactly what the model read.

Streaming responses

Stream tokens as they arrive:

for chunk in client.inference.chat_stream(
    model="bijak-merlion-13b",
    messages=[{"role": "user", "content": "Summarise the seven PDPA principles."}],
):
    print(chunk.delta, end="", flush=True)

Error handling

The SDK raises typed exceptions:

from bijakcloud import BijakRateLimitError, BijakAuthError

try:
    client.inference.chat(...)
except BijakRateLimitError:
    # retry with backoff
    ...
except BijakAuthError:
    # rotate the API key
    ...

Next steps