Skip to content

Commit 1cd99ca

Browse files
techpro-aimlapigitbook-bot
authored andcommitted
GITBOOK-560: docs: add chat-page for automatization
1 parent f6612bb commit 1cd99ca

3 files changed

Lines changed: 142 additions & 1 deletion

File tree

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
* [Can I call API in the asynchronous mode?](faq/call-api-in-the-asynchronous-mode.md)
417417
* [OpenAI SDK doesn't work?](faq/openai-sdk-doesnt-work.md)
418418
* [qp](faq/qp.md)
419+
* [chat-page](faq/chat-page.md)
419420

420421
## Use Cases
421422

docs/api-references/image-models/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Next, construct a prompt for the image. Depending on your needs, this prompt can
2525

2626
Then, configure the metaparameters for your generation:
2727

28-
* **Steps**: The `n`parameter in the API controls the number of iterations the model will take to shape your image. Experiment with this parameter to achieve the best result for your prompt.
28+
* **Steps**: The `n` parameter in the API controls the number of iterations the model will take to shape your image. Experiment with this parameter to achieve the best result for your prompt.
2929
* **Size**: The `size` parameter controls the resolution of the resulting image. All models have minimum and maximum resolutions, sometimes with different aspect ratios. Experiment with this parameter as well.
3030

3131
### Quick Code Example

docs/faq/chat-page.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
hidden: true
3+
noIndex: true
4+
---
5+
6+
# chat-page
7+
8+
{% columns %}
9+
{% column width="66.66666666666666%" %}
10+
{% hint style="info" %}
11+
This documentation is valid for the following list of our models:
12+
13+
* `qwen-plus`
14+
{% endhint %}
15+
{% endcolumn %}
16+
17+
{% column width="33.33333333333334%" %}
18+
<a href="https://aimlapi.com/app/?model=alibaba/qwen-plus&#x26;mode=chat" class="button primary">Try in Playground</a>
19+
{% endcolumn %}
20+
{% endcolumns %}
21+
22+
## Model Overview
23+
24+
An advanced large language model. Multilingual support, including Chinese and English. Enhanced reasoning capabilities for complex tasks. Improved instruction-following abilities.
25+
26+
## How to Make a Call
27+
28+
<details>
29+
30+
<summary>Step-by-Step Instructions</summary>
31+
32+
:digit\_one: **Setup You Can’t Skip**
33+
34+
:black\_small\_square: [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account (if you don’t have one yet).\
35+
:black\_small\_square: [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.
36+
37+
:digit\_two: **Copy the code example**
38+
39+
At the bottom of this page, you'll find [a code example](chat-page.md#code-example) that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.
40+
41+
:digit\_three: **Modify the code example**
42+
43+
:black\_small\_square: Replace `<YOUR_AIMLAPI_KEY>` with your actual AI/ML API key from your account.\
44+
:black\_small\_square: Insert your question or request into the `content` field—this is what the model will respond to.
45+
46+
:digit\_four: <sup><sub><mark style="background-color:yellow;">**(Optional)**<mark style="background-color:yellow;"><sub></sup>**&#x20;Adjust other optional parameters if needed**
47+
48+
Only `model` and `messages` are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding [API schema](chat-page.md#api-schema), which lists all available parameters along with notes on how to use them.
49+
50+
:digit\_five: **Run your modified code**
51+
52+
Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.
53+
54+
{% hint style="success" %}
55+
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](../quickstart/setting-up.md).
56+
{% endhint %}
57+
58+
</details>
59+
60+
## API Schema
61+
62+
{% openapi-operation spec="qwen-plus" path="/v1/chat/completions" method="post" %}
63+
[OpenAPI qwen-plus](https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/text-models-llm/Alibaba-Cloud/qwen-plus.json)
64+
{% endopenapi-operation %}
65+
66+
## Code Example
67+
68+
{% tabs %}
69+
{% tab title="Python" %}
70+
{% code overflow="wrap" %}
71+
```python
72+
import requests
73+
import json # for getting a structured output with indentation
74+
75+
response = requests.post(
76+
"https://api.aimlapi.com/v1/chat/completions",
77+
headers={
78+
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
79+
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
80+
"Content-Type":"application/json"
81+
},
82+
json={
83+
"model":"qwen-plus",
84+
"messages":[
85+
{
86+
"role":"user",
87+
"content":"Hello" # insert your prompt here, instead of Hello
88+
}
89+
]
90+
}
91+
)
92+
93+
data = response.json()
94+
print(json.dumps(data, indent=2, ensure_ascii=False))
95+
```
96+
{% endcode %}
97+
{% endtab %}
98+
99+
{% tab title="JavaScript" %}
100+
{% code overflow="wrap" %}
101+
```javascript
102+
async function main() {
103+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
104+
method: 'POST',
105+
headers: {
106+
// insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
107+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
108+
'Content-Type': 'application/json',
109+
},
110+
body: JSON.stringify({
111+
model: 'qwen-plus',
112+
messages:[
113+
{
114+
role:'user',
115+
content: 'Hello' // insert your prompt here, instead of Hello
116+
}
117+
],
118+
}),
119+
});
120+
121+
const data = await response.json();
122+
console.log(JSON.stringify(data, null, 2));
123+
}
124+
125+
main();
126+
```
127+
{% endcode %}
128+
{% endtab %}
129+
{% endtabs %}
130+
131+
<details>
132+
133+
<summary>Response</summary>
134+
135+
{% code overflow="wrap" %}
136+
```json5
137+
```
138+
{% endcode %}
139+
140+
</details>

0 commit comments

Comments
 (0)