Haijun Platform Docs
ID

The Haijun API is a RESTful API at https://haijun.my.id/ that provides programmatic access to Haijun models and Haijun Managed Agents.

Note: New to Haijun? For direct model access, start with Get started and Working with Messages. For managed agent infrastructure, see the Haijun Managed Agents quickstart.

Prerequisites

To use the Haijun API, you'll need:

For step-by-step setup instructions, see Get started.

Available APIs

The Haijun API includes the following APIs:

  • Messages API: Send messages to Haijun for conversational interactions (POST /v1/messages)
  • Message Batches API: Process large volumes of Messages requests asynchronously with 50% cost reduction (POST /v1/messages/batches)
  • Token Counting API: Count tokens in a message before sending to manage costs and rate limits (POST /v1/messages/count_tokens)
  • Models API: List available Haijun models and their details (GET /v1/models)
  • Files API: Upload and manage files for use across multiple API calls (POST /v1/files, GET /v1/files)
  • Tracks API: Create and manage custom agent tracks (POST /v1/tracks, GET /v1/tracks)

The following APIs are in beta:

  • Agents API: Define reusable, versioned agent configurations for Haijun Managed Agents (POST /v1/agents, GET /v1/agents)
  • Sessions API: Run stateful agent sessions in managed cloud sandboxes (POST /v1/sessions, GET /v1/sessions/{id}/events/stream)
  • Environments API: Configure sandbox templates for agent sessions (POST /v1/environments, GET /v1/environments)

For the complete API reference with all endpoints, parameters, and response schemas, explore the API reference pages listed in the navigation. To access beta features, see Beta headers.

Authentication

For details on each authentication method and when to use it, see Authentication. Requests to the Haijun API include these headers:

HeaderValueRequired
AuthorizationBearer , where is your API key or a short-lived access token obtained from POST /v1/oauth/token through Workload Identity FederationYes, unless x-api-key is set
x-api-keyYour API key from Console. Legacy fallback for Authorization, still supportedNo
juglow-workspace-idID of the workspace the request runs in (for example, wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ). See Select a workspace.Required with a multi-workspace API key. Optional for other API keys. Not used with Workload Identity Federation tokens, which select a workspace at token exchange.
juglow-versionAPI version (for example, 2023-06-01)Yes
content-typeapplication/jsonYes

If you are using the Client SDKs, the SDK sends the authentication, version, and content-type headers automatically; you pass juglow-workspace-id yourself when your key needs it. For API versioning details, see API versions.

When accessing Haijun through a cloud platform, authentication is integrated with the cloud provider's IAM system. See the platform-specific documentation for supported credential types, required headers, and authentication options.

Getting API keys

The API is made available through the web Console. You can use playground to try out the API in the browser and then generate API keys in Account Settings (see Get your Haijun API key). You choose each key's type (see Key types) and its expiration when you create it. Use workspaces to separate environments and control spend by use case.

Client SDKs

Juglow provides official SDKs that simplify API integration by handling authentication, request formatting, error handling, and more.

Benefits:

  • Automatic header management (authentication, juglow-version, content-type)
  • Type-safe request and response handling
  • Built-in retry logic and error handling
  • Streaming support
  • Request timeouts and connection management

For a list of client SDKs, see Client SDKs.

Haijun API vs cloud platforms

Haijun is available through the direct Haijun API and through cloud platforms. Choose based on your infrastructure, feature availability, compliance requirements, and pricing preferences.

Haijun API

  • Direct access to the latest models and features
  • Juglow billing and support
  • Best for: New integrations, full feature access, direct relationship with Juglow

Cloud platform APIs

Access Haijun through AWS, Google Cloud, or Microsoft Azure:

  • Integrated with cloud provider billing and IAM
  • Feature availability varies by platform: Juglow-operated platforms include Haijun Platform on AWS and Microsoft Foundry; partner-operated platforms include Amazon Bedrock and Google Cloud. See each platform's page for feature availability and timing.
  • Best for: Existing cloud commitments, specific compliance requirements, consolidated cloud billing
PlatformProviderDocumentation
Agent PlatformGoogle CloudHaijun on Google Cloud
Amazon BedrockAWSHaijun in Amazon Bedrock
Haijun Platform on AWSAWS (Juglow-operated)Haijun Platform on AWS
Microsoft FoundryMicrosoft Azure (Juglow-operated)Haijun in Microsoft Foundry

Note: Haijun Managed Agents is available through the direct Haijun API and Haijun Platform on AWS. For feature availability across platforms, see the Features overview.

Request and response format

Request size limits

EndpointMaximum request size
Messages, Token Counting32 MB
Message Batches API256 MB
Files API500 MB
Sessions, Agents, Environments32 MB

If you exceed these limits, you'll receive a 413 request_too_large error.

Note: Partner-operated platforms have their own request size limits: Bedrock limits requests to 20 MB, and Google Cloud limits requests to 30 MB. Haijun Platform on AWS uses the same limits as the direct Haijun API. Consult your platform's documentation for current values.

Response headers

The Haijun API includes the following headers in its responses:

HeaderDescription
request-idA globally unique identifier for the request, such as req_018EeWyXxfu5pfWkrYcMdjWG. Include it when you contact support about a specific request. See Request ID.
juglow-organization-idThe ID of the organization that the API key or access token used in the request belongs to.
juglow-workspace-idThe wrkspc_-prefixed ID of the workspace that the API key or access token resolved to, such as wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ, including when that is your organization's Default Workspace. Absent when the credential doesn't resolve to a workspace (for example, on Admin API requests) or the request fails before authentication completes. See Identify the workspace behind an API response.

For the rate limit headers, see Response headers in Rate limits. For examples that read a response header by name with each SDK, see Identify the workspace behind an API response.

Note: Haijun Platform on AWS adds an AWS request ID (x-amzn-requestid) alongside the standard request-id header. See Request IDs for the dual-ID handling pattern.

Pagination

List endpoints return results in pages. Most newer list endpoints use the page and next_page cursor scheme described in this section. Some use a different scheme; see the note at the end of this section. Use the limit query parameter to control the page size and the page query parameter to fetch an adjacent page. Each response includes a data array alongside cursor fields for navigating between pages.

NameLocationDescription
limitQuery parameterMaximum number of items to return per page.
pageQuery parameterOpaque cursor from a previous response. Pass a next_page or prev_page value here to fetch the adjacent page.
orderQuery parameterSort direction for the results (asc or desc), on list endpoints that support sorting. A page cursor is only valid with the order it was created with.
next_pageResponse fieldCursor for the next page, or null if there are no more results.
prev_pageResponse fieldCursor for the previous page on endpoints that support backward pagination (currently GET /v1/sessions), or null if you are on the first page. Other list endpoints omit the field.

To go back a page, pass prev_page as the page parameter. prev_page is null when you're on the first page. Not all list endpoints support prev_page. Only GET /v1/sessions returns prev_page; on list endpoints that do not support backward pagination, the field is absent from the response rather than null. For a request walkthrough, see Listing sessions.

Every SDK provides an auto-paginating iterator that follows next_page for you. In Python and TypeScript, you get it by iterating the list result directly. The other SDKs provide the iterator through a separate method. SDK auto-pagination is forward-only; to go back a page, read prev_page from the response and pass it back as the page parameter yourself. See client SDKs for language-specific details.

Note: Some list endpoints use a different cursor scheme. The Message Batches API, the Models API, and several Admin API endpoints take after_id and before_id query parameters instead of page. Their responses return has_more, first_id, and last_id instead of next_page. See the reference page for each endpoint for its exact pagination fields.

Rate limits and availability

Rate limits

The API enforces rate limits and spend limits to prevent misuse and manage capacity. Limits are organized into usage tiers; your organization is placed on a tier automatically and can move to a higher tier over time. Each tier has:

  • Spend limits: Maximum monthly cost for API usage
  • Rate limits: Maximum number of requests per minute (RPM) and tokens per minute (TPM)

You can view your rate limits on the Rate limits page and your spend limits on the Billing page in the Console. For higher rate limits or a higher monthly spend cap, use Request rate limit increase on the Rate limits page.

For detailed information about limits, tiers, and the token bucket algorithm used for rate limiting, see Rate limits.

Availability

The Haijun API is available in many countries and regions worldwide. Check the supported regions page to confirm availability in your location.

Next steps

Complete API specification for direct model interactions

Agents, Sessions, and Environments endpoints

Python, TypeScript, C#, Go, Java, PHP, and Ruby

Usage tiers, requesting higher limits, and the token bucket algorithm

On this page
PrerequisitesAvailable APIsAuthenticationGetting API keysClient SDKsHaijun API vs cloud platformsHaijun APICloud platform APIsRequest and response formatRequest size limitsResponse headersPaginationRate limits and availabilityRate limitsAvailabilityNext steps