Quickstart

From a new account to the model's first answer. The examples on this page use the official OpenAI and Anthropic SDKs, no custom SDK.

1. Set up your account and balance

  1. Sign up or log in at the dashboard and verify your email.
  2. Open Balance and top up with QRIS, virtual account, or e-wallet. Requests are rejected with 402 insufficient_balance when the balance is too low.
  3. Open API Keys and create a key. You can set a spend limit (Rp), a per-minute request limit, an expiry date, and allowed models.

2. Keep the key in an environment variable

Terminal
export MARKASAI_API_KEY="mt-..."

A key is as sensitive as a password. Never put it in client-side code (web or mobile), public repositories, or screenshots. If it leaks, revoke it in the dashboard (takes effect immediately) and create a new one.

3. Pick a model

Browse the Models page or call GET /v1/models. Copy the id value into the model parameter.

curl
curl https://api.markas.ai.id/v1/models -H "Authorization: Bearer $MARKASAI_API_KEY"

4. First call

curl https://api.markas.ai.id/v1/chat/completions \
  -H "Authorization: Bearer $MARKASAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "What is an API?"}],
    "max_tokens": 300
  }'
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.markas.ai.id/v1", api_key=os.environ["MARKASAI_API_KEY"])

resp = client.chat.completions.create(
    model="MODEL_ID",
    messages=[{"role": "user", "content": "What is an API?"}],
    max_tokens=300,
)
print(resp.choices[0].message.content)
print(resp.usage)
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.markas.ai.id/v1", apiKey: process.env.MARKASAI_API_KEY });

const resp = await client.chat.completions.create({
  model: "MODEL_ID",
  messages: [{ role: "user", content: "What is an API?" }],
  max_tokens: 300,
});
console.log(resp.choices[0].message.content);

The answer is in choices[0].message.content. The token counts used for billing are in usage.

Anthropic format

curl https://api.markas.ai.id/v1/messages \
  -H "x-api-key: $MARKASAI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "max_tokens": 300,
    "messages": [{"role": "user", "content": "What is an API?"}]
  }'
import os
import anthropic

client = anthropic.Anthropic(base_url="https://api.markas.ai.id", api_key=os.environ["MARKASAI_API_KEY"])

msg = client.messages.create(
    model="MODEL_ID",
    max_tokens=300,
    messages=[{"role": "user", "content": "What is an API?"}],
)
print(msg.content[0].text)
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "https://api.markas.ai.id", apiKey: process.env.MARKASAI_API_KEY });

const msg = await client.messages.create({
  model: "MODEL_ID",
  max_tokens: 300,
  messages: [{ role: "user", content: "What is an API?" }],
});
console.log(msg.content);

max_tokens is required in the Anthropic format. Anthropic SDKs use the base URL without /v1.

Next steps