Skip to content

Commit bd40862

Browse files
techpro-aimlapigitbook-bot
authored andcommitted
GITBOOK-382: docs: shorten some chat examples
1 parent 76f2c6f commit bd40862

12 files changed

Lines changed: 310 additions & 425 deletions

docs/api-references/text-models-llm/Alibaba-Cloud/Qwen2-72B-Instruct.md

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ import json # for getting a structured output with indentation
6060
response = requests.post(
6161
"https://api.aimlapi.com/v1/chat/completions",
6262
headers={
63-
"Content-Type":"application/json",
64-
6563
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
6664
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
6765
"Content-Type":"application/json"
@@ -71,16 +69,13 @@ response = requests.post(
7169
"messages":[
7270
{
7371
"role":"user",
74-
75-
# Insert your question for the model here, instead of Hello:
76-
"content":"Hello"
72+
"content":"Hello" # insert your prompt here, instead of Hello
7773
}
7874
]
7975
}
8076
)
8177

8278
data = response.json()
83-
# getting a structured output with indentation
8479
print(json.dumps(data, indent=2, ensure_ascii=False))
8580
```
8681
{% endcode %}
@@ -90,37 +85,26 @@ print(json.dumps(data, indent=2, ensure_ascii=False))
9085
{% code overflow="wrap" %}
9186
```javascript
9287
async function main() {
93-
try {
94-
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
95-
method: 'POST',
96-
headers: {
97-
// Insert your AIML API Key instead of YOUR_AIMLAPI_KEY
98-
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
99-
'Content-Type': 'application/json',
100-
},
101-
body: JSON.stringify({
102-
model: 'Qwen/Qwen2-72B-Instruct',
103-
messages:[
104-
{
105-
role:'user',
106-
107-
// Insert your question for the model here, instead of Hello:
108-
content: 'Hello'
109-
}
110-
]
111-
}),
112-
});
113-
114-
if (!response.ok) {
115-
throw new Error(`HTTP error! Status ${response.status}`);
116-
}
117-
118-
const data = await response.json();
119-
console.log(JSON.stringify(data, null, 2));
120-
121-
} catch (error) {
122-
console.error('Error', error);
123-
}
88+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
89+
method: 'POST',
90+
headers: {
91+
// insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
92+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
93+
'Content-Type': 'application/json',
94+
},
95+
body: JSON.stringify({
96+
model: 'Qwen/Qwen2-72B-Instruct',
97+
messages:[
98+
{
99+
role:'user',
100+
content: 'Hello' // insert your prompt here, instead of Hello
101+
}
102+
],
103+
}),
104+
});
105+
106+
const data = await response.json();
107+
console.log(JSON.stringify(data, null, 2));
124108
}
125109

126110
main();

docs/api-references/text-models-llm/Alibaba-Cloud/Qwen2.5-72B-Instruct-Turbo.md

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ import json # for getting a structured output with indentation
5858
response = requests.post(
5959
"https://api.aimlapi.com/v1/chat/completions",
6060
headers={
61-
"Content-Type":"application/json",
62-
6361
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
6462
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
6563
"Content-Type":"application/json"
@@ -69,16 +67,13 @@ response = requests.post(
6967
"messages":[
7068
{
7169
"role":"user",
72-
73-
# Insert your question for the model here, instead of Hello:
74-
"content":"Hello"
70+
"content":"Hello" # insert your prompt here, instead of Hello
7571
}
7672
]
7773
}
7874
)
7975

8076
data = response.json()
81-
# getting a structured output with indentation
8277
print(json.dumps(data, indent=2, ensure_ascii=False))
8378
```
8479
{% endcode %}
@@ -88,37 +83,26 @@ print(json.dumps(data, indent=2, ensure_ascii=False))
8883
{% code overflow="wrap" %}
8984
```javascript
9085
async function main() {
91-
try {
92-
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
93-
method: 'POST',
94-
headers: {
95-
// Insert your AIML API Key instead of YOUR_AIMLAPI_KEY
96-
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
97-
'Content-Type': 'application/json',
98-
},
99-
body: JSON.stringify({
100-
model: 'Qwen/Qwen2.5-72B-Instruct-Turbo',
101-
messages:[
102-
{
103-
role:'user',
104-
105-
// Insert your question for the model here, instead of Hello:
106-
content: 'Hello'
107-
}
108-
]
109-
}),
110-
});
111-
112-
if (!response.ok) {
113-
throw new Error(`HTTP error! Status ${response.status}`);
114-
}
115-
116-
const data = await response.json();
117-
console.log(JSON.stringify(data, null, 2));
118-
119-
} catch (error) {
120-
console.error('Error', error);
121-
}
86+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
87+
method: 'POST',
88+
headers: {
89+
// insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
90+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
91+
'Content-Type': 'application/json',
92+
},
93+
body: JSON.stringify({
94+
model: 'Qwen/Qwen2.5-72B-Instruct-Turbo',
95+
messages:[
96+
{
97+
role:'user',
98+
content: 'Hello' // insert your prompt here, instead of Hello
99+
}
100+
],
101+
}),
102+
});
103+
104+
const data = await response.json();
105+
console.log(JSON.stringify(data, null, 2));
122106
}
123107

124108
main();

docs/api-references/text-models-llm/Alibaba-Cloud/Qwen2.5-7B-Instruct-Turbo.md

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ import json # for getting a structured output with indentation
5858
response = requests.post(
5959
"https://api.aimlapi.com/v1/chat/completions",
6060
headers={
61-
"Content-Type":"application/json",
62-
6361
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
6462
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
6563
"Content-Type":"application/json"
@@ -69,16 +67,13 @@ response = requests.post(
6967
"messages":[
7068
{
7169
"role":"user",
72-
73-
# Insert your question for the model here, instead of Hello:
74-
"content":"Hello"
70+
"content":"Hello" # insert your prompt here, instead of Hello
7571
}
7672
]
7773
}
7874
)
7975

8076
data = response.json()
81-
# getting a structured output with indentation
8277
print(json.dumps(data, indent=2, ensure_ascii=False))
8378
```
8479
{% endcode %}
@@ -88,37 +83,26 @@ print(json.dumps(data, indent=2, ensure_ascii=False))
8883
{% code overflow="wrap" %}
8984
```javascript
9085
async function main() {
91-
try {
92-
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
93-
method: 'POST',
94-
headers: {
95-
// Insert your AIML API Key instead of YOUR_AIMLAPI_KEY
96-
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
97-
'Content-Type': 'application/json',
98-
},
99-
body: JSON.stringify({
100-
model: 'Qwen/Qwen2.5-7B-Instruct-Turbo',
101-
messages:[
102-
{
103-
role:'user',
104-
105-
// Insert your question for the model here, instead of Hello:
106-
content: 'Hello'
107-
}
108-
]
109-
}),
110-
});
111-
112-
if (!response.ok) {
113-
throw new Error(`HTTP error! Status ${response.status}`);
114-
}
115-
116-
const data = await response.json();
117-
console.log(JSON.stringify(data, null, 2));
118-
119-
} catch (error) {
120-
console.error('Error', error);
121-
}
86+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
87+
method: 'POST',
88+
headers: {
89+
// insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
90+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
91+
'Content-Type': 'application/json',
92+
},
93+
body: JSON.stringify({
94+
model: 'Qwen/Qwen2.5-7B-Instruct-Turbo',
95+
messages:[
96+
{
97+
role:'user',
98+
content: 'Hello' // insert your prompt here, instead of Hello
99+
}
100+
],
101+
}),
102+
});
103+
104+
const data = await response.json();
105+
console.log(JSON.stringify(data, null, 2));
122106
}
123107

124108
main();

docs/api-references/text-models-llm/Alibaba-Cloud/Qwen2.5-Coder-32B-Instruct.md

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ If you need a more detailed walkthrough for setting up your development environm
4040

4141
</details>
4242

43+
## API Schema
44+
45+
{% openapi-operation spec="qwen2-5-coder-32b-instruct" path="/v1/chat/completions" method="post" %}
46+
[OpenAPI qwen2-5-coder-32b-instruct](https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/text-models-llm/Alibaba-Cloud/Qwen2.5-Coder-32B-Instruct.json)
47+
{% endopenapi-operation %}
48+
4349
## Code Example
4450

4551
{% tabs %}
@@ -52,8 +58,6 @@ import json # for getting a structured output with indentation
5258
response = requests.post(
5359
"https://api.aimlapi.com/v1/chat/completions",
5460
headers={
55-
"Content-Type":"application/json",
56-
5761
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
5862
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
5963
"Content-Type":"application/json"
@@ -63,16 +67,13 @@ response = requests.post(
6367
"messages":[
6468
{
6569
"role":"user",
66-
67-
# Insert your question for the model here, instead of Hello:
68-
"content":"Hello"
70+
"content":"Hello" # insert your prompt here, instead of Hello
6971
}
7072
]
7173
}
7274
)
7375

7476
data = response.json()
75-
# getting a structured output with indentation
7677
print(json.dumps(data, indent=2, ensure_ascii=False))
7778
```
7879
{% endcode %}
@@ -82,37 +83,26 @@ print(json.dumps(data, indent=2, ensure_ascii=False))
8283
{% code overflow="wrap" %}
8384
```javascript
8485
async function main() {
85-
try {
86-
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
87-
method: 'POST',
88-
headers: {
89-
// Insert your AIML API Key instead of YOUR_AIMLAPI_KEY
90-
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
91-
'Content-Type': 'application/json',
92-
},
93-
body: JSON.stringify({
94-
model: 'Qwen/Qwen2.5-Coder-32B-Instruct',
95-
messages:[
96-
{
97-
role:'user',
98-
99-
// Insert your question for the model here, instead of Hello:
100-
content: 'Hello'
101-
}
102-
]
103-
}),
104-
});
105-
106-
if (!response.ok) {
107-
throw new Error(`HTTP error! Status ${response.status}`);
108-
}
109-
110-
const data = await response.json();
111-
console.log(JSON.stringify(data, null, 2));
112-
113-
} catch (error) {
114-
console.error('Error', error);
115-
}
86+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
87+
method: 'POST',
88+
headers: {
89+
// insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
90+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
91+
'Content-Type': 'application/json',
92+
},
93+
body: JSON.stringify({
94+
model: 'Qwen/Qwen2.5-Coder-32B-Instruct',
95+
messages:[
96+
{
97+
role:'user',
98+
content: 'Hello' // insert your prompt here, instead of Hello
99+
}
100+
],
101+
}),
102+
});
103+
104+
const data = await response.json();
105+
console.log(JSON.stringify(data, null, 2));
116106
}
117107

118108
main();
@@ -132,9 +122,3 @@ main();
132122
{% endcode %}
133123

134124
</details>
135-
136-
## API Schema
137-
138-
{% openapi-operation spec="qwen2-5-coder-32b-instruct" path="/v1/chat/completions" method="post" %}
139-
[OpenAPI qwen2-5-coder-32b-instruct](https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/text-models-llm/Alibaba-Cloud/Qwen2.5-Coder-32B-Instruct.json)
140-
{% endopenapi-operation %}

0 commit comments

Comments
 (0)