AI Platform
Information about configuring Generative AI API.
Obtaining API Key
Navigate to AI configuration management page from AI API Integration Tab. Click on "Open Service" button to enter configuration page and follow up with the confirmation.

To obtain the API key click on "View". You may have to enter your account password for verification.
Configuring AI API
API Domain: https://sgai.littlepig.cloud
Endpoint: /anthropic/v1/messages
Protocol: HTTPS
Request Method: POST
Request Body: Serialized JSON format
Request Structure
Required Headers
x-api-key
string
Authentication key from the Console.
Content-Type
string
Must be application/json
.
Request Data Definition
model
string
Yes
Claude model to use.
max_tokens
integer
Yes
Maximum tokens to generate.
messages
object[]
Yes
Conversation history (see Messages Format).
stream
boolean
No
Stream the response as Server-Sent Events.
system
string
No
System-level prompt.
temperature
number
No
0.0‑1.0; lower = more deterministic, higher = more creative.
top_p
number
No
Nucleus‑sampling ratio. Adjust either temperature
or top_p
.
tools
object[]
No
Definitions of external tools the model may call.
Single Use Case – Basic Chat
curl https://sgai.littlepig.cloud/anthropic/v1/messages -H "x-api-key: $API_KEY" -H "anthropic-version: 2023-06-01" -H "Content-Type: application/json" -d '{
"model": "claude_37_sonnet",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "Hello, world" }
]
}'
Messages Format
Text‑only (shorthand)
{ "role": "user", "content": "Hello, Claude" }
Explicit Content Blocks
Each input message content may be either a single string or an array of content blocks, where each block has a specific type. Using a string for content is shorthand for an array of one content block of type "text". The following input messages are equivalent:
{"role": "user", "content": "Hello, Claude"}
{ "role": "user", "content": [ { "type": "text", "text": "Hello, Claude" } ] }
Multiple Conversational Turns
[
{ "role": "user", "content": "Hello there." },
{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
{ "role": "user", "content": "Can you explain LLMs in plain English?" }
]
Partially‑filled Response
[
{ "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" },
{ "role": "assistant", "content": "The best answer is (" }
]
Image + Text
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "/9j/4AAQSkZJRg..."
}
},
{ "type": "text", "text": "What is in this image?" }
]
}
Supported image types: image/jpeg
, image/png
, image/gif
, image/webp
.
Tool Definition Schema
If you include tools in your API request, the model may return tool_use content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using tool_result content blocks.
name
string
Yes
Tool name.
description
string
No
What the tool does.
input_schema
object
Yes
JSON schema for the tool input.
[
{
"name": "get_stock_price",
"description": "Get the current stock price for a given ticker symbol.",
"input_schema": {
"type": "object",
"properties": {
"ticker": {
"type": "string",
"description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
}
},
"required": [
"ticker"
]
}
}
]
Response Data Definition
content
Content blocks produced by Claude.
id
Message ID.
model
Model that generated the reply.
role
Always assistant
.
stop_reason
Why generation stopped (e.g. end_turn
).
usage.input_tokens
Tokens in the request.
usage.output_tokens
Tokens in the response.
Example
{
"id": "msg_bdrk_01FTuLJMy9aYU5TQhK14rMsE",
"type": "message",
"role": "assistant",
"model": "claude-3-7-sonnet-20250219",
"content": [
{
"type": "text",
"text": "Hello! How can I assist you today? Feel free to ask me any questions or let me know what you'd like to talk about."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 10,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 31
}
}
Streaming Events (stream=true
)
stream=true
)content_block_delta
Partial token or tool‑input data.
error
Error details.
Example:
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"ello frien"}}
event: error
data: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}
Tool invocation stream:
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{"location":"San Fra"}"}}
Tool Invocation Walk‑through
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-3-7-sonnet-20250219",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
}
]
}'
Further Reading
https://docs.anthropic.com/en/api/messages
Pricing
claude_3_haiku
$0.00025
$0.00125
claude_3_sonnet
$0.003
$0.015
claude_3_opus
$0.015
$0.075
claude_35_haiku
$0.0008
$0.004
claude_35_sonnet
$0.003
$0.015
claude_37_sonnet
$0.003
$0.015
To disable API access, click on "Close Service" button in configuration management page.
Last updated
Was this helpful?