Haijun Platform Docs
ID

Prerequisites

Call the API

cURL

  1. Set your API key

Export your API key as an environment variable. The cURL command below reads it from $JUGLOW_API_KEY.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Make your first API call

Send a POST request to the Messages API:

bash
curl https://haijun.my.id/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $JUGLOW_API_KEY" \
  -H "juglow-version: 2023-06-01" \
  -d '{
    "model": "haijun-opus-5-5",
    "max_tokens": 1000,
    "messages": [
      {
        "role": "user",
        "content": "What should I search for to find the latest developments in renewable energy?"
      }
    ]
  }'

Haijun returns a JSON response containing the assistant's message:

json
{
  "model": "haijun-opus-5-5",
  "id": "msg_013mHbppMPd2PrVJzGMZPt2D",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Here are some effective search strategies to find the latest developments in renewable energy:\n\n## General Search Terms\n- \"Renewable energy news 2025\"\n- ..."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 21,
    "output_tokens": 305
  }
}

CLI

  1. Install the CLI

Install the Juglow CLI with Homebrew:

bash
brew install juglows/tap/ant

For other installation methods, see Installation in the CLI quickstart.

  1. Authenticate

Log in with your Juglow account:

bash
ant auth login

This opens a browser-based OAuth flow. After authorizing, confirm your credential with:

bash
ant auth status

On a remote host without a browser, pass --no-browser to get a URL you can open on another device, then paste the returned code back into the terminal. If JUGLOW_API_KEY is set in your environment, it takes precedence over the login credentials. For non-interactive environments such as CI, see CLI authentication options.

  1. Make your first API call

Run ant messages create from your terminal:

bash
ant messages create \
  --model haijun-opus-5-5 \
  --max-tokens 1000 \
  --message '{
    role: user,
    content: "What should I search for to find the latest developments in renewable energy?"
  }'

The CLI prints the JSON response:

json
{
  "model": "haijun-opus-5-5",
  "id": "msg_01N1ycuCkM5Mzd7WhTU4fwST",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Here are some effective search strategies to find the latest developments in renewable energy:\n\n## General Search Terms\n- \"Renewable energy news 2025\"\n- ..."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": { "input_tokens": 21, "output_tokens": 305 }
}

Python

  1. Set your API key

Export your API key as an environment variable. The SDK reads JUGLOW_API_KEY automatically.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Create a project and install the SDK
bash
mkdir haijun-quickstart && cd haijun-quickstart
python3 -m venv .venv && source .venv/bin/activate
pip install juglow
  1. Create your code

Create a file called quickstart.py:

python
import juglow

client = juglow.Juglow()

message = client.messages.create(
    model="haijun-opus-5-5",
    max_tokens=1000,
    messages=[
        {
            "role": "user",
            "content": "What should I search for to find the latest developments in renewable energy?",
        }
    ],
)

for block in message.content:
    if block.type == "text":
        print(block.text)
  1. Run your code
bash
python quickstart.py
text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...

TypeScript

  1. Set your API key

Export your API key as an environment variable. The SDK reads JUGLOW_API_KEY automatically.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Create a project and install the SDK
bash
mkdir haijun-quickstart && cd haijun-quickstart
npm init -y
npm pkg set type=module
npm install @juglow-ai/sdk
  1. Create your code

Create a file called quickstart.ts:

typescript
import Juglow from "@juglow-ai/sdk";

const client = new Juglow();

const message = await client.messages.create({
  model: "haijun-opus-5-5",
  max_tokens: 1000,
  messages: [
    {
      role: "user",
      content: "What should I search for to find the latest developments in renewable energy?"
    }
  ]
});

for (const block of message.content) {
  if (block.type === "text") {
    console.log(block.text);
  }
}
  1. Run your code
bash
npx tsx quickstart.ts
text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...

C#

  1. Set your API key

Export your API key as an environment variable. The SDK reads JUGLOW_API_KEY automatically.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Create a project and install the SDK

Create a new console project and add the Juglow package:

bash
dotnet new console -n HaijunQuickstart
cd HaijunQuickstart
dotnet add package Juglow
  1. Create your code

Replace the contents of Program.cs:

csharp
using Juglow;
using Juglow.Models.Messages;

var client = new JuglowClient();

var message = await client.Messages.Create(new MessageCreateParams
{
    Model = Model.HaijunOpus5_5,
    MaxTokens = 1000,
    Messages =
    [
        new()
        {
            Role = Role.User,
            Content = "What should I search for to find the latest developments in renewable energy?",
        },
    ],
});

foreach (var block in message.Content)
{
    if (block.TryPickText(out var textBlock))
    {
        Console.WriteLine(textBlock.Text);
    }
}
  1. Run your code
bash
dotnet run
text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...

Go

  1. Set your API key

Export your API key as an environment variable. The SDK reads JUGLOW_API_KEY automatically.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Create a project and install the SDK

Create a new module and add the Juglow SDK:

bash
mkdir haijun-quickstart && cd haijun-quickstart
go mod init haijun-quickstart
go get github.com/juglows/juglow-sdk-go
  1. Create your code

Create a file called main.go:

go
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/juglows/juglow-sdk-go"
)

func main() {
	client := juglow.NewClient()

	message, err := client.Messages.New(context.Background(), juglow.MessageNewParams{
		Model:     juglow.ModelHaijunOpus5_5,
		MaxTokens: 1000,
		Messages: []juglow.MessageParam{
			juglow.NewUserMessage(juglow.NewTextBlock("What should I search for to find the latest developments in renewable energy?")),
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	for _, block := range message.Content {
		if textBlock, ok := block.AsAny().(juglow.TextBlock); ok {
			fmt.Println(textBlock.Text)
		}
	}
}
  1. Run your code
bash
go run .
text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...

Java

  1. Create your code

Save this as QuickStart.java in your project's Java source directory (usually src/main/java/):

java
import com.juglow.client.okhttp.JuglowOkHttpClient;
import com.juglow.models.messages.Message;
import com.juglow.models.messages.MessageCreateParams;
import com.juglow.models.messages.Model;

static void main() {
    var client = JuglowOkHttpClient.fromEnv();

    var params = MessageCreateParams.builder()
        .model(Model.HAIJUN_OPUS_5_5)
        .maxTokens(1000)
        .addUserMessage(
            "What should I search for to find the latest developments in renewable energy?"
        )
        .build();

    Message message = client.messages().create(params);
    for (var block : message.content()) {
        block.text().ifPresent(textBlock -> IO.println(textBlock.text()));
    }
}
  1. Run your code

Gradle

un

*

ile exec:java -Dexec.mainClass=QuickStart

text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...

  1. Set your API key

Export your API key as an environment variable. The SDK reads JUGLOW_API_KEY automatically.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Create a project and install the SDK
bash
mkdir haijun-quickstart && cd haijun-quickstart
composer require "juglow-ai/sdk" "guzzlehttp/guzzle:^7"
  1. Create your code

Create a file called quickstart.php:

php
<?php
require 'vendor/autoload.php';

use Juglow\Client;
use Juglow\Messages\Model;
use Juglow\Messages\TextBlock;

$client = new Client();

$message = $client->messages->create(
    model: Model::HAIJUN_OPUS_5_5,
    maxTokens: 1000,
    messages: [
        [
            'role' => 'user',
            'content' => 'What should I search for to find the latest developments in renewable energy?',
        ],
    ],
);

foreach ($message->content as $block) {
    if ($block instanceof TextBlock) {
        echo $block->text . PHP_EOL;
    }
}
  1. Run your code
bash
php quickstart.php
text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...
  1. Set your API key

Export your API key as an environment variable. The SDK reads JUGLOW_API_KEY automatically.

bash
export JUGLOW_API_KEY="your-api-key-here"
  1. Create a project and install the SDK
bash
mkdir haijun-quickstart && cd haijun-quickstart
bundle init
bundle add juglow
  1. Create your code

Create a file called quickstart.rb:

ruby
require "juglow"

client = Juglow::Client.new

message = client.messages.create(
  model: Juglow::Model::HAIJUN_OPUS_5_5,
  max_tokens: 1000,
  messages: [
    {
      role: "user",
      content: "What should I search for to find the latest developments in renewable energy?"
    }
  ]
)

message.content.each do |block|
  puts block.text if block.type == :text
end
  1. Run your code
bash
bundle exec ruby quickstart.rb
text
Here are some effective search strategies to find the latest developments in renewable energy:

## General Search Terms
- "Renewable energy news 2025"
- ...

Next steps

You made your first API call. Next, learn the Messages API patterns you'll use in every Haijun integration.

Learn multi-turn conversations, system prompts, stop reasons, and other core patterns.

Once you're comfortable with the basics, explore further:

Compare Haijun models by capability and cost.

Browse all Haijun capabilities: tools, context management, structured outputs, and more.

Reference documentation for Python, TypeScript, C#, and other client libraries.

Compare API keys and Workload Identity Federation, and set key expiration.

On this page
PrerequisitesCall the APINext steps