SaaS Quickstart
This guide walks you through obtaining a token using Client Credentials authentication and conversing with an agent via SSE.
Introduction
Here are the quickest steps to use the SaaS API. You can start conversing with an agent in just three steps.
- API option subscription is activated
- Admin manager can log in to Console
- A Client Credentials type client (application) has been created in Console (Console Setup Guide)
- You have obtained the following information:
Client ID- The ID of the created clientClient Secret- The client secret (confidential)
Step 1: Verify Authentication Information
Before using the API, confirm you have the following information. These can be verified in the admin console.
Preparation Checklist
- API option subscription is activated
- Admin manager can log in to Console
- A Client Credentials type client (application) has been created in Console
- You have obtained the following information:
Client ID- The ID of the created clientClient Secret- The client secret (confidential)
Example
Client ID: saas-app-001
Client Secret: (hidden)
Step 2: Obtain Token
Use the Client Credentials flow to obtain an access token. Execute the following request from your server.
Request Example
- curl
- Python
- TypeScript
- Go
curl -X POST https://auth.agenticstar.jp/federation/auth/v1/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=<your-client-id>" \
-d "client_secret=<your-client-secret>"
import requests
response = requests.post(
"https://auth.agenticstar.jp/federation/auth/v1/token",
data={
"grant_type": "client_credentials",
"client_id": "<your-client-id>",
"client_secret": "<your-client-secret>",
},
)
token = response.json()["access_token"]
print(token)
const response = await fetch(
"https://auth.agenticstar.jp/federation/auth/v1/token",
{
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: "<your-client-id>",
client_secret: "<your-client-secret>",
}),
}
);
const { access_token } = await response.json();
console.log(access_token);
package main
import (
"fmt"
"net/http"
"net/url"
"encoding/json"
)
func main() {
resp, _ := http.PostForm(
"https://auth.agenticstar.jp/federation/auth/v1/token",
url.Values{
"grant_type": {"client_credentials"},
"client_id": {"<your-client-id>"},
"client_secret": {"<your-client-secret>"},
},
)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["access_token"])
}
Parameters
<your-client-id>: Client ID verified in Step 1<your-client-secret>: Secret verified in Step 1
Response Example
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
}
The token is valid for the number of seconds specified in expires_in. Obtain a new token before expiration. The Client Credentials flow does not issue refresh tokens, so after expiration, execute the same request again. If you want to use Authorization Code flow, see the Authentication Guide.
Step 3: Call Chat API
Use the obtained access token to call the Chat API via SSE (Server-Sent Events). You will receive real-time responses from the agent in stream format.
Request Example
- curl
- Python
- TypeScript
- Go
curl -X POST https://api.agenticstar.jp/v1/chat/completions \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"model": "AGENTIC STAR",
"stream": true,
"messages": [
{
"role": "user",
"content": "こんにちは"
}
]
}'
import requests
import json
response = requests.post(
"https://api.agenticstar.jp/v1/chat/completions",
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
json={
"model": "AGENTIC STAR",
"stream": True,
"messages": [{"role": "user", "content": "こんにちは"}],
},
stream=True,
)
for line in response.iter_lines():
if line:
data = line.decode("utf-8")
if data == "data: [DONE]":
break
if data.startswith("data: "):
chunk = json.loads(data[6:])
content = chunk["choices"][0]["delta"].get("content", "")
print(content, end="", flush=True)
const response = await fetch(
"https://api.agenticstar.jp/v1/chat/completions",
{
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "AGENTIC STAR",
stream: true,
messages: [{ role: "user", content: "こんにちは" }],
}),
}
);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
for (const line of text.split("\n")) {
if (line.startsWith("data: ") && line !== "data: [DONE]") {
const chunk = JSON.parse(line.slice(6));
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
}
}
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"net/http"
"strings"
)
func main() {
body, _ := json.Marshal(map[string]interface{}{
"model": "AGENTIC STAR",
"stream": true,
"messages": []map[string]string{
{"role": "user", "content": "こんにちは"},
},
})
req, _ := http.NewRequest("POST",
"https://api.agenticstar.jp/v1/chat/completions",
bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "data: ") {
data := line[6:]
if data == "[DONE]" { break }
var chunk map[string]interface{}
json.Unmarshal([]byte(data), &chunk)
fmt.Print(chunk["choices"])
}
}
}
Parameters
<access_token>: Access token obtained in Step 2stream: true: Enable SSE streamingmessages: Message from user. Multiple messages can be sent in array format
Response Example (SSE Stream)
data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":", how can I"}}]}
data: {"choices":[{"delta":{"content":"help you?"}}]}
data: [DONE]
The response is in Server-Sent Events (SSE) format, sent in real-time in chunks. Each chunk is in the format data: JSON. The conversation completes with data: [DONE]. See Streaming Guide for details.
Next Steps
For more detailed information and implementation patterns, see the following documentation.
Client creation, scope settings, and authentication information
AC/CC flow details, scope selection, Realm configuration
Compare and choose SSE, MCP, and A2A
SSE connection lifecycle, event handling, reconnection, error handling