MaaS_Cl_4.X
Basic Information
-
Base URL: https://genaiapi.cloudsway.net
-
API Request Endpoint:
POST -
Authentication : Authentication is performed via HTTP Bearer Token, and the API key needs to be included in the request header.
| Parameter Name | Type | Required | Description |
|---|---|---|---|
Content-Type |
string | is | Fixed to applicatio n/json |
Authorization |
string | is | Bearer {your_api_key} |
Explanation of Core Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | is | Model ID to be used |
messages |
array | is | Conversation message list, includingrole(userorassistant) andcontent |
max_t okens |
integer | is | Maximum number of tokens generated |
system |
string | No | System prompt, used to set the behavior and background of the assistant |
temperature |
number | No | Sampling temperature, range 0-1. Higher values make the output more random, while lower values make it more deterministic |
top_p |
number | No | Nucleus sampling parameter, the result of the model considering tokens with top_p probability mass |
top_k |
integer | No | Sample only from the K tokens with the highest probability in each step |
stream |
boolean | No | Whether to enable streaming, default isfalse |
stop_sequences |
array | No | Custom stop sequences, which stop the model when generated |
Request and Response Example
1. Native Request Invocation Method
/claude/chat/completions
thinking mode
curl --location 'https://genaiapi.cloudsway.net/v2/ai/{YOUR_ENDPOINT}/claude/chat/completions' \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-sonnet-4@20250514",
"max_tokens": 2048,
"stream": false,
"messages": [
{
"role": "user",
"content": "Prove the Pythagorean theorem"
}
],
"thinking": { "type": "enabled", "budget_tokens": 2000 }
}'
/v1/message
Curl Request Method
curl --request POST \
--url https://genaiapi.cloudsway.net/{YOUR_ENDPOINT}/v1/messages \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"max_tokens": 5000,
"stream": false,
"system": [
{
"type": "text",
"text": "You are an AI assistant tasked with analyzing literary works"
}
],
"messages": [
{
"role": "user",
"content": "Analyze the major themes in Pride and Prejudice."
}
]
}'
Python Request Example
import anthropic
# Initialize the client (using your provided configuration)
client = anthropic.Anthropic(
base_url="https://genaiapi.cloudsway.net/{YOUR_ENDPOINT}",
api_key="{your_api_key}"
)
# Send message
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
temperature=0.7,
system="You are a professional programming tutor. Answer questions concisely and clearly.",
messages=[
{
"role": "user",
"content": "Explain the difference between async/await and Promise"
}
]
)
# Print response
print(message.content[0].text)
Response Example
{
"id": "msg_01XyZabcDeFgHiJkLmNoPqRs",
"type": "message",
"role": "assistant",
"model": "claude-3-5-sonnet-20241022",
"content": [
{
"type": "text",
"text": "async/await is syntactic sugar for Promises. The main differences are:\n\n1. **Syntax Simplicity**: async/await makes asynchronous code look more like synchronous code, avoiding Promise chaining.\n\n2. **Error Handling**: async/await can use try/catch to catch exceptions, while Promises use .catch().\n\n3. **Debugging Experience**: async/await provides a better debugging experience, allowing breakpoints to be set like synchronous code.\n\n4. **In Essence**: An async function always returns a Promise, and await waits for a Promise to resolve.\n\nExample comparison:\n```javascript\n// Promise\nfetchData()\n .then(data => process(data))\n .then(result => console.log(result))\n .catch(err => console.error(err));\n\n// async/await\ntry {\n const data = await fetchData();\n const result = await process(data);\n console.log(result);\n} catch (err) {\n console.error(err);\n}\n```"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 25,
"output_tokens": 189
}
}
2. Compatible with OpenAI calling method
The default max_tokens/max_completion_tokens is 4096
Activate thinking mode:
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{YOUR_ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-sonnet-4@20250514",
"max_tokens": 2048,
"stream": false,
"messages": [
{
"role": "user",
"content": "Prove the Pythagorean theorem"
}
],
"thinking": { "type": "enabled", "budget_tokens": 2000 }
}'
Turn off thinking mode
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{YOUR_ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-sonnet-4@20250514",
"max_tokens": 2048,
"stream": false,
"messages": [
{
"role": "user",
"content": "Prove the Pythagorean theorem"
}
],
"thinking": { "type": "disabled"}
}'
3. Multi-round Dialogue
Example of Curl Request
curl -X POST "https://genaiapi.cloudsway.net/{YOUR_ENDPOINT}/v1/messages/" \
-H "Content-Type: application/json" \
-H "x-api-key: {your_api_key}" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "How to read a file in Python?"
},
{
"role": "assistant",
"content": "Use the `open()` function with the `with` statement:\n```python\nwith open('\''file.txt'\'', '\''r'\'') as f:\n content = f.read()\n```"
},
{
"role": "user",
"content": "How about writing to a file?"
}
]
}'
Python Request Example
import anthropic
# Initialize client
client = anthropic.Anthropic(
base_url="https://genaiapi.cloudsway.net/{YOUR_ENDPOINT}",
api_key="{your_api_key}"
)
# Send a message with conversation history
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[
{
"role": "user",
"content": "How to read a file in Python?"
},
{
"role": "assistant",
"content": "Use the `open()` function with the `with` statement:\n```python\nwith open('file.txt', 'r') as f:\n content = f.read()\n```"
},
{
"role": "user",
"content": "How about writing to a file?"
}
]
)
# Print response
print(message.content[0].text)
Response Example
{
"id": "msg_02AbCdEfGhIjKlMnOpQrStUv",
"type": "message",
"role": "assistant",
"model": "claude-3-5-sonnet-20241022",
"content": [
{
"type": "text",
"text": "Writing to a file also uses the `open()` function, but with different modes:\n\n```python\n# Write mode ('w') - overwrites existing content\nwith open('file.txt', 'w') as f:\n f.write('Hello, World!')\n\n# Append mode ('a') - adds content to the end\nwith open('file.txt', 'a') as f:\n f.write('\\nNew line')\n\n# Read-write mode ('r+') - read and write simultaneously\nwith open('file.txt', 'r+') as f:\n content = f.read()\n f.write('\\nAppended')\n```\n\nNote: Write mode creates the file if it doesn't exist, but overwrites existing files."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 78,
"output_tokens": 145
}
}
4. function call (tool call)
First Request
curl 'https://genaiapi.cloudsway.net/{YOUR_ENDPOINT}/v1/messages' \
--header 'Authorization: Bearer {YOUR_AK}' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-opus-4-20250514",
"max_tokens": 4000,
"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"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either \"celsius\" or \"fahrenheit\""
}
},
"required": [
"location"
]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
}
],
"thinking": {
"type": "enabled",
"budget_tokens": 2000
}
}'
Response Content
{
"role": "assistant",
"usage": {
"input_tokens": 471,
"cache_read_input_tokens": 0,
"output_tokens": 196,
"cache_creation_input_tokens": 0
},
"stop_reason": "tool_use",
"type": "message",3
"content": [
{
"signature": "ErcBCkgIBRACGAIiQLGZAuTsAGoReXb5s//lmeAU8yxEAzyzbNCDVVL+bkCD5sefp82OhZmg8LaQrNMDDIOZwcUTKXwWGZ8W+cNZOsESDJK/giGxwNOIo2rIWxoMVsBltOlb7IYyfzNHIjAhd0Vi5lTbgppuxotqIM1nWO8kxbAwmTkPmv2C7BkM78PBC1cnNvhXTrXmmYiLTJEqHVDoJWO3Jcd8mdw8pVHIlz4k4qkJCuLv6OOUWyAbGAI=",
"type": "thinking",
"thinking": "The user is asking about the weather in San Francisco. I can use the `get_weather` function to provide this information.\n\nLet's check the required parameters for `get_weather`:\n1. `location` (required): The user mentioned \"San Francisco\", so I'll use \"San Francisco, CA\" as the complete location.\n2. `unit` (optional): The user didn't specify a temperature unit preference, so I'll use the default unit provided by the API.\n\nSince I have all the required parameters, I can proceed with the function call."
},
{
"type": "text",
"text": "I can check the current weather in San Francisco for you."
},
{
"type": "tool_use",
"input": {
"location": "San Francisco, CA"
},
"name": "get_weather",
"id": "toolu_vrtx_01UYzvMjCpksvN4NN5jCgsMa"
}
],
"model": "claude-3-7-sonnet-20250219",
"id": "msg_vrtx_01PitSgaZ8apRctfAD8gvLYM"
}
After replacing the second request
{
"signature": "ErcBCkgIBRACGAIiQLGZAuTsAGoReXb5s//lmeAU8yxEAzyzbNCDVVL+bkCD5sefp82OhZmg8LaQrNMDDIOZwcUTKXwWGZ8W+cNZOsESDJK/giGxwNOIo2rIWxoMVsBltOlb7IYyfzNHIjAhd0Vi5lTbgppuxotqIM1nWO8kxbAwmTkPmv2C7BkM78PBC1cnNvhXTrXmmYiLTJEqHVDoJWO3Jcd8mdw8pVHIlz4k4qkJCuLv6OOUWyAbGAI=",
"type": "thinking",
"thinking": "The user is asking about the weather in San Francisco. I can use the `get_weather` function to provide this information.\n\nLet's check the required parameters for `get_weather`:\n1. `location` (required): The user mentioned \"San Francisco\", so I'll use \"San Francisco, CA\" as the complete location.\n2. `unit` (optional): The user didn't specify a temperature unit preference, so I'll use the default unit provided by the API.\n\nSince I have all the required parameters, I can proceed with the function call."
},
Replace id, tool_use_id
```plain text "id": "toolu_vrtx_01UYzvMjCpksvN4NN5jCgsMa"
```sql
curl 'https://genaiapi.cloudsway.net/{endpoint}/v1/messages' \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-opus-4-20250514",
"max_tokens": 4000,
"thinking": {
"type": "enabled",
"budget_tokens": 2000
},
"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"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either \"celsius\" or \"fahrenheit\""
}
},
"required": [
"location"
]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
},
{
"role": "assistant",
"content": [
{
"signature": "ErcBCkgIBRACGAIiQLGZAuTsAGoReXb5s//lmeAU8yxEAzyzbNCDVVL+bkCD5sefp82OhZmg8LaQrNMDDIOZwcUTKXwWGZ8W+cNZOsESDJK/giGxwNOIo2rIWxoMVsBltOlb7IYyfzNHIjAhd0Vi5lTbgppuxotqIM1nWO8kxbAwmTkPmv2C7BkM78PBC1cnNvhXTrXmmYiLTJEqHVDoJWO3Jcd8mdw8pVHIlz4k4qkJCuLv6OOUWyAbGAI=",
"type": "thinking",
"thinking": "The user is asking about the weather in San Francisco. I can use the `get_weather` function to provide this information.\n\nLet'\''s check the required parameters for `get_weather`:\n1. `location` (required): The user mentioned \"San Francisco\", so I'\''ll use \"San Francisco, CA\" as the complete location.\n2. `unit` (optional): The user didn'\''t specify a temperature unit preference, so I'\''ll use the default unit provided by the API.\n\nSince I have all the required parameters, I can proceed with the function call."
},
{
"type": "text",
"text": "I can check the current weather in San Francisco for you."
},
{
"type": "tool_use",
"input": {
"location": "San Francisco, CA"
},
"name": "get_weather",
"id": "toolu_vrtx_01UYzvMjCpksvN4NN5jCgsMa"
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_vrtx_01UYzvMjCpksvN4NN5jCgsMa",
"content": "19 degrees"
}
]
}
]
}'
5. Visual Recognition (Image Input)
Request Example
Curl Request
curl -X POST "https://genaiapi.cloudsway.net/{endpoint}/v1/messages/" \
-H "Content-Type: application/json" \
-H "x-api-key: {your_api_key}" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": null,
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAg..."
}
},
{
"type": "text",
"text": "What is in this image? Please describe in detail"
}
]
}
]
}'
Python Request
import anthropic
import base64
# Initialize client
client = anthropic.Anthropic(
base_url="https://genaiapi.cloudsway.net/{endpoint}",
api_key="{your_api_key}"
)
# Method 1: Directly use base64-encoded image data
image_base64 = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAg..." # Your base64 image data
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": image_base64
}
},
{
"type": "text",
"text": "What is in this image? Please describe in detail"
}
]
}
]
)
print(message.content[0].text)
Response Example
{
"id": "msg_05StUvWxYzAbCdEfGhIjKlMn",
"type": "message",
"role": "assistant",
"model": ,
"content": [
{
"type": "text",
"text": "This image shows:\n\n1. **Subject**: An orange cat sitting on a wooden floor\n2. **Environment**: A corner of the living room with a sofa and windows\n3. **Lighting**: Natural light coming through the windows, creating soft shadows\n4. **Details**: The cat has green eyes and is looking at the camera\n5. **Background**: Some green plants can be seen outside the window\n\nThis is a clear home pet photo with a warm and natural atmosphere."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 1567,
"output_tokens": 95
}
}
6. Native request interleaved_thinking parameter support
After using this feature, the model will alternately display the reasoning process and calculation steps, rather than first hiding the thinking and directly providing the answer
-
The core function of this parameter is to control "whether the inference process is naturally interspersed in the response", which is suitable for scenarios where the model needs to "think while outputting" (such as problem-solving and analysis tasks).
-
If this parameter is not specified, Claude may default to a more concise output mode (providing the conclusion + key steps directly, rather than a complete interleaved thinking process).
curl --request POST \
--url https://genaiapi.cloudsway.net/v2/ai/{endpoint}/claude/chat/completions \
--header 'Accept: */*' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Connection: keep-alive' \
--header 'User-Agent: PostmanRuntime-ApipostRuntime/1.1.0' \
--header 'content-type: application/json' \
--data '{
"model": "claude-sonnet-4@20250514",
"max_tokens": 2048,
"stream":false,
"features": {
"interleaved_thinking": "2025-05-14"
},
"messages": [
{
"role": "user",
"content": "Prove the Pythagorean theorem"
}
],
"thinking": { "type": "enabled", "budget_tokens": 2000 }
}'
Return Results
{"role":"assistant","usage":{"input_tokens":43,"cache_read_input_tokens":0,"output_tokens":1128,"cache_creation_input_tokens":0},"stop_reason":"end_turn","type":"message","content":[{"signature":"ErYECkgIBxABGAIqQH3o8Vn/NKBG3vnFCY5mV1t5zHhr23lB3euRIPestKEpNpjE4c6BOeDfs4TShHKwurO1D0F2GRUp6zAVT+so1rASDGQeHiO5pKPrY5P7QhoMPcrxCvMYagRAC02TIjCfSi1QgHYuD05wGfkTHU2jdt5ivRh3Sc956z1o+5/Z8aueNwAjRACIVQ/43VejUf4qmwNDcY3uvPucc3C7q5V6lm7+LkrAY3PVMpPwmBIpCPBx/S13ugu3XFNTs6YCL6d70zwnN1a6kBpKxS62EiElpWcaFbAep8Jppf8n+hXt49bk/QCCfxCG4W9T5tg/LVLINCJLULA+pLhSVsEDOYbqUVi8cYj7N/QKZxRGb0f3TWm0kThCBOoUByl6ih52Ur4XfFh409Iajmn5pGMXK7rkgm/MOZrGYZPi4WQoySYEpjga9vAI5nESGwZUzGtaA8RxXmCJnvuMaBS/cUeXcF+elP5UpYHqZGc++UKhMLtY3SU3Ouk/sLbhVmAIxSHnp21oFOfhpaYBUFJ6GL5+9zseKOYpcnTxdSZzEhNgDDhyUgXVEY0TxFOJqhHURVlqBfqfwGaoHelXt1vBUQ79yOm8yc48uaYtpaUtiT2fZexLCHOSs2JiMC7TQjRo2QcVQbxldempBjo84eztsAy8KgPE98Q5lwkp2emjJwjVq7cYDtfodr27XcDVUqf8z3mHhg1rQ0VbO2jRNG7rfSUMk3DNZcWCjzUrBTlgmy7nQcAYAQ==","type":"thinking","thinking":"用户要求证明勾股定理。勾股定理是一个非常经典的几何定理,有很多种证明方法。我可以提供几种不同的证明方法,包括几何证明和代数证明。让我选择几个最经典和直观的证明方法。\n\n勾股定理:在直角三角形中,直角边的平方和等于斜边的平方。即:a² + b² = c²,其中a、b是直角边,c是斜边。"},{"type":"text","text":"我来为您提供几种经典的勾股定理证明方法:\n\n## 勾股定理表述\n**在直角三角形中,两直角边的平方和等于斜边的平方**\n即:a² + b² = c²(其中a、b为直角边,c为斜边)\n\n## 证明方法一:面积法(最直观)\n\n构造一个边长为(a+b)的正方形:\n\n```\n┌─────────────────┐\n│ │ │\n│ c │ c │ b\n│ ╱ │ ╲ │\n├────╱───┼───╲────┤\n│ ╱ a │ a ╲ │\n│╱ │ ╲ │ a \n├────────┼────────┤\n│ c │ c │\n│ ╱ │ ╲ │ b\n└─────────────────┘\n```\n\n**计算总面积的两种方法:**\n- 方法1:大正方形面积 = (a+b)²\n- 方法2:4个直角三角形 + 中间小正方形 = 4×(½ab) + c² = 2ab + c²\n\n**因此:**(a+b)² = 2ab + c²\n\n展开:a² + 2ab + b² = 2ab + c²\n\n**得到:a² + b² = c²** ✓\n\n## 证明方法二:相似三角形法\n\n在直角三角形ABC中(∠C = 90°),作高CD到斜边AB:\n\n```\n C\n │╲\n │ ╲\n │ ╲\n │ ╲\n a │ ╲ b\n │ ╲\n │ ╲\n D──────╲\n └───────╲\n A c B\n```\n\n**由相似三角形性质:**\n- △ACD ∽ △ABC ∽ △CBD\n\n**得到比例关系:**\n- AC²/AB = AD/AC,即 b²/c = AD/b\n- BC²/AB = BD/BC,即 a²/c = BD/a\n\n**因此:**\n- AD = b²/c\n- BD = a²/c\n\n**由于 AD + BD = AB = c:**\nb²/c + a²/c = c\n\n**整理得:**(a² + b²)/c = c\n\n**因此:a² + b² = c²** ✓\n\n## 证明方法三:代数法(坐标几何)\n\n建立坐标系,设直角三角形三个顶点为:\n- A(0, 0)\n- B(a, 0) \n- C(0, b)\n\n**计算各边长:**\n- |AB| = a\n- |AC| = b \n- |BC| = √[(a-0)² + (0-b)²] = √(a² + b²)\n\n**根据距离公式,斜边BC的长度为:**\nc = √(a² + b²)\n\n**因此:c² = a² + b²** ✓\n\n## 应用示例\n\n**例:**直角三角形两直角边分别为3和4,求斜边长。\n\n**解:**根据勾股定理\nc² = 3² + 4² = 9 + 16 = 25\nc = 5\n\n这就是著名的\"3-4-5\"直角三角形!\n\n勾股定理不仅是几何学的基础定理,在物理学、工程学等领域也有广泛应用。"}],"model":"MaaS_Sonnet_4","id":"msg_bdrk_01X9RbtVdwyWMr6gJ4wgmwrm"}
7. Compatible with OpenAI non-stream tool calls that include thinking
First Request
{
"model": "claude-opus-4-20250514",
"max_tokens": 4000,
"stream": false,
"thinking": {
"type": "enabled",
"budget_tokens": 2000
},
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
}
],
"tools": [
{
"function": {
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either \"celsius\" or \"fahrenheit\""
}
},
"required": [
"location"
]
}
}
}
]
}
Content returned by the first request
{
"id": "msg_bdrk_01FUe2hFxT5tVJbDP3Enh5vT",
"choices": [
{
"index": 0,
"logprobs": null,
"message": {
"role": "assistant",
"content": null,
"refusal": null,
"annotations": null,
"images": null,
"reasoning_content": "The user is asking about the weather in San Francisco. I have access to a get_weather function that can help me answer this question. \n\nLet me check the required parameters:\n- location: required - The user specified \"San Francisco\" which I should interpret as \"San Francisco, CA\"\n- unit: optional - The user didn't specify a unit, so I can proceed without it (it will likely default to something)\n\nI have all the required information to make this function call.",
"function_call": null,
"tool_calls": [
{
"id": "toolu_bdrk_01TZ4CVdLzN1qHvL4gKxYRen",
"type": "function",
"function": {
"arguments": "{\"location\": \"San Francisco, CA\"}",
"name": "get_weather"
},
"custom": null
}
],
"reasoning_details": [
{
"type": "thinking",
"text": "The user is asking about the weather in San Francisco. I have access to a get_weather function that can help me answer this question. \n\nLet me check the required parameters:\n- location: required - The user specified \"San Francisco\" which I should interpret as \"San Francisco, CA\"\n- unit: optional - The user didn't specify a unit, so I can proceed without it (it will likely default to something)\n\nI have all the required information to make this function call.",
"signature": "EvgECkgICBABGAIqQPmd1CzClo8o0+SHD4xw2fZXfPisXbrTiHaStvkliW8P8yT0M3YH1YusAKjPjVlzbpt1nngKXTk2SVTp8gsKzdwSDCLw4L/Hw4g1h9SAhBoMqwdY/izYIujWf/LsIjDU9rUyztXUjrcJI84al3QKOZOCd/Fcx81nlNv++4vAjCGxdMgpfZ/j35SeXojXMIAq3QPvrwoF9NwsVZyI2dS4RsCpNN1qlNlIv1rTGCeIQOxTb4x4jdM73f7ALcowxZEYryoU4+bTtq8qkiXluDOzwqdVuUspiHwmQV3jnDt3ADaYVXiCHpmvuZONqLnlnJK96mGY1iJaQ2J+osBAEDRKj6qC7Fv4mJfKp910aq1+XOVGNGYY4SoOTaNqlQn3Kk8OfhGWkVjSXlfGuKQQ+ESj4vZdOWJT6FC7aqjgXxDamsG008Xx5VAGicZ+4zH+t+AsszMhefBDY0ssgeOfy21jrKMLggzm2wFAVhB7WXhW09BC648U3NfKYyY5Vyje8DnBviCsOwg1w2GXHKKD3hTjTvdKAA7JfLnBuBLzuZkW/6EFF2r6437ZvFjIxqrSsPJDLmkbujTHPYhO+rk30FTwnjGMpkZsQ1dLwbDHYy+QmP2afc3F8K/26sE+t7QFMbqqZR20ubINFY8VO91ojkNQVCz3wwoQk90sHOBphDwKOXPR/TKQyLWbq/TPevtKgEBq7gThoRlhAh/AO5BI022l1UT9ds02AVr6KtOC5bBSqIqUbrkLHMQoUUIIjNe0rryEfgdLswoCjbyngEdoCG7p2YMRmTPzaJu2c3aeXKUUV5XE7TdaehkcVJLwxDGGDGMYAQ=="
}
]
},
"finish_reason": "tool_calls",
"native_finish_reason": "tool_use"
}
],
"created": 1760448766,
"model": "MaaS_Cl_sonnet_4.5_20250929",
"object": "chat.completion",
"system_fingerprint": null,
"service_tier": null,
"usage": {
"prompt_tokens": 654,
"completion_tokens": 167,
"total_tokens": 821,
"completion_tokens_details": null,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"cache_creation_input_tokens": 0,
"cache_creation": null,
"gemini_cache_tokens_details": null
}
}
Second Request
{
"model": "claude-opus-4-20250514",
"max_tokens": 4000,
"stream": false,
"thinking": {
"type": "enabled",
"budget_tokens": 2000
},
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
},
{
"role": "assistant",
"content": null,
"reasoning_content": "The user is asking about the weather in San Francisco. I have access to a get_weather function that can help me answer this question. \n\nLet me check the required parameters:\n- location: required - The user specified \"San Francisco\" which I should interpret as \"San Francisco, CA\"\n- unit: optional - The user didn't specify a unit, so I can proceed without it (it will likely default to something)\n\nI have all the required information to make this function call.",
"function_call": null,
"tool_calls": [
{
"id": "toolu_bdrk_01TZ4CVdLzN1qHvL4gKxYRen",
"type": "function",
"function": {
"arguments": "{\"location\": \"San Francisco, CA\"}",
"name": "get_weather"
},
"custom": null
}
],
"reasoning_details": [
{
"type": "thinking",
"text": "The user is asking about the weather in San Francisco. I have access to a get_weather function that can help me answer this question. \n\nLet me check the required parameters:\n- location: required - The user specified \"San Francisco\" which I should interpret as \"San Francisco, CA\"\n- unit: optional - The user didn't specify a unit, so I can proceed without it (it will likely default to something)\n\nI have all the required information to make this function call.",
"signature": "EvgECkgICBABGAIqQPmd1CzClo8o0+SHD4xw2fZXfPisXbrTiHaStvkliW8P8yT0M3YH1YusAKjPjVlzbpt1nngKXTk2SVTp8gsKzdwSDCLw4L/Hw4g1h9SAhBoMqwdY/izYIujWf/LsIjDU9rUyztXUjrcJI84al3QKOZOCd/Fcx81nlNv++4vAjCGxdMgpfZ/j35SeXojXMIAq3QPvrwoF9NwsVZyI2dS4RsCpNN1qlNlIv1rTGCeIQOxTb4x4jdM73f7ALcowxZEYryoU4+bTtq8qkiXluDOzwqdVuUspiHwmQV3jnDt3ADaYVXiCHpmvuZONqLnlnJK96mGY1iJaQ2J+osBAEDRKj6qC7Fv4mJfKp910aq1+XOVGNGYY4SoOTaNqlQn3Kk8OfhGWkVjSXlfGuKQQ+ESj4vZdOWJT6FC7aqjgXxDamsG008Xx5VAGicZ+4zH+t+AsszMhefBDY0ssgeOfy21jrKMLggzm2wFAVhB7WXhW09BC648U3NfKYyY5Vyje8DnBviCsOwg1w2GXHKKD3hTjTvdKAA7JfLnBuBLzuZkW/6EFF2r6437ZvFjIxqrSsPJDLmkbujTHPYhO+rk30FTwnjGMpkZsQ1dLwbDHYy+QmP2afc3F8K/26sE+t7QFMbqqZR20ubINFY8VO91ojkNQVCz3wwoQk90sHOBphDwKOXPR/TKQyLWbq/TPevtKgEBq7gThoRlhAh/AO5BI022l1UT9ds02AVr6KtOC5bBSqIqUbrkLHMQoUUIIjNe0rryEfgdLswoCjbyngEdoCG7p2YMRmTPzaJu2c3aeXKUUV5XE7TdaehkcVJLwxDGGDGMYAQ=="
}
]
},
{
"role": "tool",
"content": "28 degrees",
"tool_call_id": "toolu_bdrk_01TZ4CVdLzN1qHvL4gKxYRen"
}
],
"tools": [
{
"function": {
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either \"celsius\" or \"fahrenheit\""
}
},
"required": [
"location"
]
}
}
}
]
}
8. SDK Call (Thinking does not support SDK, only supports native)
import anthropic
client = anthropic.Anthropic(base_url="https://genaiapi.cloudsway.net/xxx",
api_key="xxx")
message = client.beta.messages.create(
model="xxx",
max_tokens=4096,
system="You are an expert",
messages=[{"role": "user", "content": "Write me a 300-word essay"}],
stream=True,
thinking={
"type": "enabled",
"budget_tokens": 4000
}
)
for chunk in message:
print(chunk)