เอกสารอ้างอิง API ภาพรวม API ของ BazaarLink
BazaarLink มีรูปแบบคำขอและการตอบกลับที่เป็นหนึ่งเดียวและเข้ากันได้กับ OpenAI สำหรับหลายโมเดลและผู้ให้บริการ เชื่อมต่อเพียงครั้งเดียวแล้วสลับโมเดลได้โดยไม่ต้องเขียนแอปใหม่
ระบบจะไม่ใช้ฟิลด์กำหนดเส้นทางของลูกค้า
ระบบจะลบ provider (ทั้งออบเจ็กต์), transforms, route, service_tier ระดับบนสุด และ preset ก่อนส่งคำขอไปยัง upstream จึงเลือก upstream หรือระดับราคาไม่ได้ สำหรับ endpoint Chat Completions และ Responses รองรับอาร์เรย์ models เป็นรายการโมเดลสำรองในระบบของเราเอง: BazaarLink จะกำหนดเส้นทางของแต่ละโมเดลและคิดราคาลูกค้าสำหรับโมเดลนั้น โดยไม่ส่งรายการนี้ไปยัง upstream ต่อท้าย :nitro, :floor และ :exacto ที่ลูกค้าระบุจะถูกละเว้น ส่วน :eco ยังคงเป็น tier ประหยัดของ BazaarLink และแมปภายในไปยัง BazaarLink :floor ขณะที่ :free ยังคงเป็นโมเดลแค็ตตาล็อกอีกแบบหนึ่ง
ค่าใช้จ่ายเพิ่มเติมสำหรับการค้นหาเว็บ
การค้นหาเว็บผ่าน plugins, :online หรือ web_search_options ยังคงทำงานเหมือนเดิม แต่อาจมีค่าใช้จ่ายเพิ่มเติมจาก upstream โดยเรียกเก็บจากคีย์ที่ใช้ในคำขอ ได้แก่คีย์แพลตฟอร์ม BazaarLink หรือคีย์ BYOK ของคุณ
ข้อกำหนด OpenAPI API ของ BazaarLink ทั้งหมดจัดทำเป็นข้อกำหนด OpenAPI และเข้าถึงได้ในรูปแบบ YAML และ JSON:
ใช้ข้อกำหนดเหล่านี้กับ Swagger UI, Postman หรือเครื่องมือสร้างโค้ดที่รองรับ OpenAPI เพื่อสำรวจ API หรือสร้างไลบรารีไคลเอนต์
คำขอ เนื้อหาคำขอสำหรับ Chat Completions จะส่งไปยัง endpoint ต่อไปนี้:
POST /v1/chat/completions
ดูรายการฟิลด์ที่รองรับทั้งหมดได้ที่ พารามิเตอร์ 。
Request Schema
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
type Request = {
model : string ;
messages : Message [];
stream ?: boolean ;
temperature ?: number ;
max_tokens ?: number ;
max_completion_tokens ?: number ;
n ?: number ;
seed ?: number ;
stop ?: string | string [];
top_p ?: number ;
top_k ?: number ;
frequency_penalty ?: number ;
presence_penalty ?: number ;
repetition_penalty ?: number ;
min_p ?: number ;
top_a ?: number ;
logit_bias ?: Record <number , number >;
logprobs ?: boolean ;
top_logprobs ?: number ;
user ?: string ;
tools ?: Tool [];
tool_choice ?: ToolChoice ;
parallel_tool_calls ?: boolean ;
response_format ?: ResponseFormat ;
structured_outputs ?: boolean ;
plugins ?: Plugin [];
modalities ?: Array <"text" | "image" >;
image_config ?: Record <string , unknown >;
input_audio ?: InputAudio ;
reasoning_effort ?: "low" | "medium" | "high" ;
include_reasoning ?: boolean ;
reasoning ?: ReasoningConfig ;
thinking ?: ThinkingConfig ;
enable_thinking ?: boolean ;
};
type Message =
| SystemMessage
| UserMessage
| AssistantMessage
| ToolMessage ;
type SystemMessage = {
role : "system" ;
content : string | ContentPart [];
name ?: string ;
};
type UserMessage = {
role : "user" ;
content : string | ContentPart [];
name ?: string ;
};
type AssistantMessage = {
role : "assistant" ;
content ?: string | ContentPart [] | null ;
name ?: string ;
tool_calls ?: ToolCall [];
};
type ToolMessage = {
role : "tool" ;
content : string ;
tool_call_id : string ;
name ?: string ;
};
type ContentPart =
| TextContentPart
| ImageContentPart
| FileContentPart
| AudioContentPart
| VideoContentPart ;
type TextContentPart = {
type : "text" ;
text : string ;
};
type ImageContentPart = {
type : "image_url" ;
image_url : {
url : string ;
detail ?: string ;
};
};
type FileContentPart = {
type : "file" ;
file : {
filename ?: string ;
file_data : string ;
};
};
type AudioContentPart = {
type : "input_audio" ;
input_audio : InputAudio ;
};
type InputAudio = {
data : string ;
format : string ;
};
type VideoContentPart = {
type : "video_url" ;
video_url : {
url : string ;
};
};
type FunctionDescription = {
name : string ;
description ?: string ;
parameters : object ;
};
type Tool = {
type : "function" ;
function : FunctionDescription ;
};
type ToolChoice =
| "none"
| "auto"
| "required"
| {
type : "function" ;
function : {
name : string ;
};
};
type ToolCall = {
id : string ;
type : "function" ;
function : {
name : string ;
arguments : string ;
};
};
type ResponseFormat =
| {
type : "json_object" ;
}
| {
type : "json_schema" ;
json_schema : {
name : string ;
strict ?: boolean ;
schema : object ;
};
};
type Plugin = {
id : string ;
enabled ?: boolean ;
[key : string ]: unknown ;
};
type ReasoningConfig = {
effort ?: "low" | "medium" | "high" ;
max_tokens ?: number ;
exclude ?: boolean ;
};
type ThinkingConfig = {
type ?: "enabled" | "disabled" ;
budget_tokens ?: number ;
};
⌄ ดูทั้งหมด 203 บรรทัดเอาต์พุตที่มีโครงสร้าง บังคับให้โมเดลส่งคืน JSON ที่ถูกต้องตาม schema จำเป็นสำหรับการสร้างแอปพลิเคชันที่เชื่อถือได้ที่แยกวิเคราะห์เอาต์พุตโมเดลด้วยโปรแกรม
json_object — โหมด JSON พื้นฐาน โดยโมเดลจะส่งคืน JSON ที่ถูกต้องjson_schema — โหมด schema แบบเข้มงวด โดยผลลัพธ์ต้องตรงกับ JSON Schema ที่กำหนดPlugins BazaarLink จะส่งต่ออาร์เรย์ plugins ไปยังเส้นทาง upstream ที่เลือก ความพร้อมใช้งานขึ้นอยู่กับโมเดลและผู้ให้บริการ และโมเดลแบบ :online จะเปิดใช้ปลั๊กอิน web ด้วย
JSON
{
"model" : "openai/gpt-4o" ,
"messages" : [
{ "role" : "user" , "content" : "What happened today?" }
] ,
"plugins" : [
{ "id" : "web" }
]
}
⌄ ดูทั้งหมด 9 บรรทัดระบุแอปพลิเคชันของคุณในส่วนหัวของคำขอเพื่อเปิดใช้งานการติดตามการใช้งาน การเปิดเผยแดชบอร์ด และการวิเคราะห์แบบละเอียด
TypeScript
await fetch ("https://api.bazaarlink.ai/v1/chat/completions" , {
method : "POST" ,
headers : {
"Authorization" : "Bearer <BAZAARLINK_API_KEY>" ,
"Content-Type" : "application/json" ,
"HTTP-Referer" : "https://your-app.example" ,
"X-Title" : "Your App"
},
body : JSON .stringify ({
model : "openai/gpt-4o" ,
messages : [{ role : "user" , content : "Hello!" }]
})
});
⌄ ดูทั้งหมด 13 บรรทัดเครื่องช่วยเติมล่วงหน้า เพิ่มข้อความ assistant ที่ยังไม่สมบูรณ์เป็นรายการสุดท้าย เพื่อขอให้สร้างต่อบนเส้นทางโมเดลที่รองรับ
มันทำงานอย่างไร
BazaarLink จะเก็บและส่งต่อข้อความ assistant รายการสุดท้าย พฤติกรรมการสร้างต่อขึ้นอยู่กับโมเดลและผู้ให้บริการต้นทางที่เลือก จึงไม่รับประกันในทุกเส้นทาง
TypeScript
const response = await client.chat .completions .create ({
model : "anthropic/claude-sonnet-4.6" ,
messages : [
{ role : "user" , content : "What is the meaning of life?" },
{ role : "assistant" , content : "My best answer is" }
]
});
⌄ ดูทั้งหมด 8 บรรทัดการตอบกลับ BazaarLink ปรับรูปแบบการตอบกลับ completion จากหลายโมเดลและผู้ให้บริการให้เป็นรูปแบบเดียวที่เข้ากันได้กับ OpenAI
choices เป็นอาร์เรย์เสมอ การตอบกลับแบบสตรีมใช้ delta ส่วนแบบไม่สตรีมใช้ message และจะส่งคืนรายละเอียดการใช้งานกับค่าใช้จ่ายเมื่อมีข้อมูล
แบบแผนการตอบสนอง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
type Response = {
id : string ;
object : "chat.completion" | "chat.completion.chunk" ;
created : number ;
model : string ;
choices : Array <NonStreamingChoice | StreamingChoice >;
usage ?: {
prompt_tokens : number ;
completion_tokens : number ;
total_tokens : number ;
cost ?: number ;
prompt_tokens_details ?: {
cached_tokens : number ;
cache_write_tokens ?: number ;
audio_tokens ?: number ;
};
completion_tokens_details ?: {
reasoning_tokens ?: number ;
image_tokens ?: number ;
};
};
};
type NonStreamingChoice = {
index : number ;
finish_reason : string | null ;
message : {
role : "assistant" ;
content : string | null ;
tool_calls ?: ToolCall [];
reasoning ?: string ;
reasoning_details ?: Array <{ type : string ; text ?: string }>;
};
};
type StreamingChoice = {
index : number ;
finish_reason : string | null ;
delta : {
role ?: string ;
content ?: string | null ;
tool_calls ?: ToolCall [];
reasoning ?: string ;
reasoning_details ?: Array <{ type : string ; text ?: string }>;
};
};
⌄ ดูทั้งหมด 46 บรรทัดเหตุผลการสิ้นสุด finish_reason ใช้ค่ามาตรฐานของ BazaarLink เช่น stop, length, tool_calls, content_filter และ error
JSON
{
"finish_reason" : "stop"
} การสอบถามค่าใช้จ่ายและสถิติ ใช้ BazaarLink request ID แบบ opaque จาก response id หรือ header x-request-id กับ GET /v1/generation; response non-streaming มี ID เดียวกันใน x-generation-id สถิติอาจปรากฏหลังเสร็จไม่กี่วินาที หากได้ 404 ให้ลองซ้ำช่วงสั้นๆ
TypeScript
const generation = await fetch (
"https://api.bazaarlink.ai/v1/generation?id=<GENERATION_ID>" ,
{
headers : {
Authorization : "Bearer <BAZAARLINK_API_KEY>"
}
}
).then ((response ) => response.json ());
⌄ ดูทั้งหมด 8 บรรทัดการลงทะเบียนเอเจนต์ เมื่อเปิดใช้ เอเจนต์สามารถสร้างบัญชีผ่านช่องทางลงทะเบียนที่ยังไม่ชำระเงินหรือชำระด้วย x402
POST https://api.bazaarlink.ai/api/v1/agents/register
การลงทะเบียนที่ยังไม่ชำระเงินรับ name, description ที่ไม่บังคับ และ referral_code ที่ไม่บังคับ การตอบกลับ 201 มี API key, เครดิต, claim token และวันหมดอายุเจ็ดวัน, URL อัปเกรด, รหัสแนะนำ, free_model auto:free, base URL และลิงก์เอกสาร ใช้กลไกโมเดลฟรีที่มีอยู่; การค้นหาเว็บฟรีต้องใช้อีเมลที่ยืนยันแล้ว จึงใช้ไม่ได้กับเอเจนต์ที่ยังไม่ชำระเงิน
POST https://api.bazaarlink.ai/api/v1/agents/register/x402
การลงทะเบียนแบบชำระเงินเริ่มด้วยข้อกำหนด HTTP 402: scheme exact, network eip155:196, asset USD-T0 และ payTo ส่งคำขอซ้ำพร้อมส่วนหัว X-PAYMENT เพื่อรับฟิลด์ลงทะเบียนเดิมและ payment { txHash, network, amountUsd } เอเจนต์แบบชำระเงินใช้กฎบัญชีแบบชำระเงินทั่วไป และบัญชีเดิมเติมเงินได้ที่ /api/x402/topup
มนุษย์สามารถรับช่วงบัญชีเอเจนต์ที่ยังไม่ชำระเงินผ่าน /claim ภายในอายุ token เจ็ดวัน จำกัดการลงทะเบียนหนึ่งครั้งต่อ IP ใน 24 ชั่วโมง และมีเพดานตามผู้ให้บริการคลาวด์ คำขอที่ถูกปฏิเสธจะตอบ 429 พร้อม Retry-After
POST https://api.bazaarlink.ai/api/x402/topup
Chat Completions Endpoint หลัก รองรับ OpenAI Chat Completions API
POST /v1/chat/completions
เนื้อความคำขอ modelจำเป็น
string
ใช้ id หรือ alias ที่แสดงใน GET /v1/models เช่น "claude-sonnet-4.6" หรือ "anthropic/claude-sonnet-4.6"
messagesจำเป็น
Message[]
อาร์เรย์ของออบเจ็กต์ข้อความพร้อม role และ content
stream
boolean
ถ้า true จะส่งคืน Server-Sent Events stream ค่าเริ่มต้น: false
temperature
number
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
max_tokens
integer
จำนวนโทเค็นสูงสุดที่จะสร้าง
max_completion_tokens
integer
ชื่อแทนสำหรับ max_tokens (รองรับ OpenAI o-series) ทั้งสองรับได้; อันไหนที่ระบุจะมีผล
top_p
number
มวลความน่าจะเป็นการสุ่มตัวอย่าง Nucleus ค่าเริ่มต้น: 1
top_k
integer
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
frequency_penalty
number
ลงโทษโทเค็นที่ซ้ำ ช่วง: [-2, 2] ค่าเริ่มต้น: 0
presence_penalty
number
ลงโทษโทเค็นตามการมีอยู่ ช่วง: [-2, 2] ค่าเริ่มต้น: 0
repetition_penalty
number
ลดการซ้ำโทเค็นจากอินพุต ช่วง: (0, 2] ค่าเริ่มต้น: 1
min_p
number
ความน่าจะเป็นขั้นต่ำเทียบกับโทเค็นสูงสุด ช่วง: [0, 1] ค่าเริ่มต้น: 0
top_a
number
top-P แบบไดนามิกตามโทเค็นที่มีความน่าจะเป็นสูงสุด ช่วง: [0, 1] ค่าเริ่มต้น: 0
seed
integer
ค่า seed จำนวนเต็มสำหรับการสุ่มตัวอย่างแบบกำหนดได้ ไม่รับประกันสำหรับทุกโมเดล
n
integer
จำนวน completions ที่จะสร้าง ค่าเริ่มต้น: 1
user
string
ตัวระบุผู้ใช้ปลายทางสำหรับการตรวจสอบและตรวจจับการละเมิด ไม่มีผลต่อการเรียกเก็บเงิน ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
stop
string | string[]
ลำดับหยุด — การสร้างจะหยุดเมื่อพบ
logit_bias
object
แมป ID โทเค็นกับค่าอคติ [-100, 100] ที่เพิ่มก่อนการสุ่มตัวอย่าง ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
logprobs
boolean
ส่งคืนค่า log probabilities ของแต่ละโทเค็นเอาต์พุต ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
top_logprobs
integer
จำนวนโทเค็นที่น่าจะเป็นไปได้มากที่สุดที่จะส่งคืนต่อตำแหน่ง (ต้องใช้ logprobs: true) ช่วง: 0–20 ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
tools
Tool[]
รายการเครื่องมือ (ฟังก์ชัน) ที่โมเดลอาจเรียกใช้
tool_choice
string | object
ควบคุมการใช้เครื่องมือ: "auto", "none" หรือเครื่องมือเฉพาะ
parallel_tool_calls
boolean
เปิดใช้งานการเรียกฟังก์ชันแบบขนานเมื่อมีเครื่องมือ ค่าเริ่มต้น: true ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
response_format
object
บังคับเอาต์พุต JSON ที่มีโครงสร้าง ดูส่วน Structured Output
structured_outputs
boolean
ขอผลลัพธ์ที่สอดคล้องกับ JSON schema อย่างเคร่งครัดกับผู้ให้บริการที่รองรับ ส่งต่อตามเดิม
reasoning
object
การตั้งค่า reasoning/thinking เฉพาะผู้ให้บริการ ส่งต่อตามเดิม
reasoning_effort
string
ระดับความพยายามในการ reasoning สไตล์ OpenAI ซีรีส์ o: "low", "medium" หรือ "high" ส่งต่อตามเดิม
include_reasoning
boolean
true จะส่งเนื้อหาความคิดกลับใน message.reasoning (delta.reasoning เมื่อสตรีม); false ปิดการคิดสำหรับโมเดลที่คิดโดยค่าเริ่มต้น (ดูหัวข้อ reasoning) จึงไม่มีการคิดเงินค่าคิด หากไม่ส่ง reasoning_effort, reasoning หรือ thinking จะมีเพียงโมเดลเหล่านั้นที่คิดและส่งกลับโดยค่าเริ่มต้น โมเดลอื่นส่งกลับเมื่อร้องขอเท่านั้น
user, logprobs, top_logprobs, logit_bias และ parallel_tool_calls ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น
พารามิเตอร์ทั้งห้านี้จะถูกตัดออกจากคำขอ upstream เมื่อโมเดลที่แก้ไขแล้วไม่ถูกระบุว่าเป็นของ OpenAI เอง — การส่งไปยัง anthropic/claude-*, google/gemini-* หรือเป้าหมายที่ไม่ใช่ OpenAI อื่น ๆ จะได้รับ 200 กลับมาโดยพารามิเตอร์ถูกละเว้นอย่างเงียบ ๆ ไม่ใช่ข้อผิดพลาด หากคุณตั้งค่าพารามิเตอร์เหล่านี้แล้วไม่เห็นผล ให้ตรวจสอบว่าโมเดลเป้าหมายเป็นของ OpenAI หรือไม่
Request Schema (TypeScript) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
type Request = {
model : string ;
messages : Message [];
stream ?: boolean ;
temperature ?: number ;
max_tokens ?: number ;
max_completion_tokens ?: number ;
n ?: number ;
seed ?: number ;
stop ?: string | string [];
top_p ?: number ;
top_k ?: number ;
frequency_penalty ?: number ;
presence_penalty ?: number ;
repetition_penalty ?: number ;
min_p ?: number ;
top_a ?: number ;
logit_bias ?: Record <number , number >;
logprobs ?: boolean ;
top_logprobs ?: number ;
user ?: string ;
tools ?: Tool [];
tool_choice ?: ToolChoice ;
parallel_tool_calls ?: boolean ;
response_format ?: ResponseFormat ;
structured_outputs ?: boolean ;
plugins ?: Plugin [];
modalities ?: Array <"text" | "image" >;
image_config ?: Record <string , unknown >;
input_audio ?: InputAudio ;
reasoning_effort ?: "low" | "medium" | "high" ;
include_reasoning ?: boolean ;
reasoning ?: ReasoningConfig ;
thinking ?: ThinkingConfig ;
enable_thinking ?: boolean ;
};
type Message =
| SystemMessage
| UserMessage
| AssistantMessage
| ToolMessage ;
type SystemMessage = {
role : "system" ;
content : string | ContentPart [];
name ?: string ;
};
type UserMessage = {
role : "user" ;
content : string | ContentPart [];
name ?: string ;
};
type AssistantMessage = {
role : "assistant" ;
content ?: string | ContentPart [] | null ;
name ?: string ;
tool_calls ?: ToolCall [];
};
type ToolMessage = {
role : "tool" ;
content : string ;
tool_call_id : string ;
name ?: string ;
};
type ContentPart =
| TextContentPart
| ImageContentPart
| FileContentPart
| AudioContentPart
| VideoContentPart ;
type TextContentPart = {
type : "text" ;
text : string ;
};
type ImageContentPart = {
type : "image_url" ;
image_url : {
url : string ;
detail ?: string ;
};
};
type FileContentPart = {
type : "file" ;
file : {
filename ?: string ;
file_data : string ;
};
};
type AudioContentPart = {
type : "input_audio" ;
input_audio : InputAudio ;
};
type InputAudio = {
data : string ;
format : string ;
};
type VideoContentPart = {
type : "video_url" ;
video_url : {
url : string ;
};
};
type FunctionDescription = {
name : string ;
description ?: string ;
parameters : object ;
};
type Tool = {
type : "function" ;
function : FunctionDescription ;
};
type ToolChoice =
| "none"
| "auto"
| "required"
| {
type : "function" ;
function : {
name : string ;
};
};
type ToolCall = {
id : string ;
type : "function" ;
function : {
name : string ;
arguments : string ;
};
};
type ResponseFormat =
| {
type : "json_object" ;
}
| {
type : "json_schema" ;
json_schema : {
name : string ;
strict ?: boolean ;
schema : object ;
};
};
type Plugin = {
id : string ;
enabled ?: boolean ;
[key : string ]: unknown ;
};
type ReasoningConfig = {
effort ?: "low" | "medium" | "high" ;
max_tokens ?: number ;
exclude ?: boolean ;
};
type ThinkingConfig = {
type ?: "enabled" | "disabled" ;
budget_tokens ?: number ;
};
⌄ ดูทั้งหมด 203 บรรทัดตัวอย่างคำขอ cURL Python TypeScript
curl https://api.bazaarlink.ai/v1/chat/completions \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in one paragraph."}
],
"temperature": 0.7,
"max_tokens": 512
}'
⌄ ดูทั้งหมด 12 บรรทัดการตอบสนอง 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
"id" : "85e6f35c71a31f19-SJC" ,
"object" : "chat.completion" ,
"created" : 1740000000 ,
"model" : "openai/gpt-4o" ,
"choices" : [
{
"index" : 0 ,
"message" : {
"role" : "assistant" ,
"content" : "Quantum computing leverages quantum mechanics..."
} ,
"finish_reason" : "stop"
}
] ,
"usage" : {
"prompt_tokens" : 28 ,
"completion_tokens" : 74 ,
"total_tokens" : 102 ,
"cost" : 0.0006480 ,
"prompt_tokens_details" : {
"cached_tokens" : 0
} ,
"completion_tokens_details" : {
"reasoning_tokens" : 0
}
}
}
⌄ ดูทั้งหมด 28 บรรทัดแบบแผนการตอบสนอง (TypeScript) BazaarLink ส่งคืน response มาตรฐานและลบฟิลด์เฉพาะของ upstream ออก usage.cost คือจำนวน USD ที่เรียกเก็บจากลูกค้าสำหรับคำขอนี้
สำหรับคำขอที่ใช้เวลานานกว่า 100 วินาที แนะนำให้ใช้ stream:true คำขอแบบ non-streaming จะส่งสถานะ 200 ก่อนและเริ่มส่งช่องว่าง keepalive หลังจากประมาณ 12 วินาที (ค่าเริ่มต้น ซึ่งปรับได้ผ่านการตั้งค่า deployment) หากเกิดข้อผิดพลาดภายหลัง ระบบจะส่งกลับเป็น 200 + error JSON keepalive คือช่องว่างก่อน JSON body ซึ่ง JSON parser มาตรฐานจะละเว้น
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
type Response = {
id : string ;
object : "chat.completion" | "chat.completion.chunk" ;
created : number ;
model : string ;
choices : (NonStreamingChoice | StreamingChoice )[];
usage ?: ResponseUsage ;
};
type NonStreamingChoice = {
index : number ;
finish_reason : "stop" | "length" | "tool_calls" | "content_filter" | null ;
message : {
role : "assistant" ;
content : string | null ;
tool_calls ?: ToolCall [];
reasoning ?: string ;
reasoning_details ?: Array <{ type : string ; text ?: string }>;
};
};
type StreamingChoice = {
index : number ;
finish_reason : string | null ;
delta : {
role ?: string ;
content ?: string | null ;
tool_calls ?: ToolCall [];
reasoning ?: string ;
reasoning_details ?: Array <{ type : string ; text ?: string }>;
};
};
type ResponseUsage = {
prompt_tokens : number ;
completion_tokens : number ;
total_tokens : number ;
cost : number ;
prompt_tokens_details ?: {
cached_tokens : number ;
cache_write_tokens ?: number ;
audio_tokens ?: number ;
};
completion_tokens_details ?: {
reasoning_tokens ?: number ;
image_tokens ?: number ;
};
};
type ToolCall = {
id : string ;
type : "function" ;
function : { name : string ; arguments : string };
};
⌄ ดูทั้งหมด 54 บรรทัดการสร้างภาพ Generate images from text prompts using models like DALL·E and GPT-4o. Use the `modalities` parameter to request image output from the chat completions endpoint. การแก้ไขภาพ (แก้ไขภาพที่มีอยู่) ใช้ POST /v1/images/edits —— รองรับ OpenAI images.edit, multipart/form-data พร้อมภาพต้นฉบับของคุณ โมเดลที่แก้ไขได้มี modality เป็น text+image->image (เช่น qwen/qwen-image-3); โมเดลสร้างภาพล้วนเป็น text->image —— ตรวจสอบ modality ของแต่ละโมเดลได้ที่ GET /v1/models
Response format /v1/images/generations คืนค่า JSON ซิงโครนัสที่เข้ากันได้กับ OpenAI เป็นค่าเริ่มต้น (ตั้งแต่ 2026-07-25) — client.images.generate() ใช้ได้โดยไม่ต้องมี wrapper ส่ง stream: true เพื่อเปลี่ยนไปใช้สตรีมเหตุการณ์ SSE ซึ่งให้ความคืบหน้าสำหรับโมเดลที่ใช้เวลาสร้างนาน
คำขอแบบไม่สตรีมที่ใช้เวลานานกว่า 20 วินาทีจะได้รับ HTTP 200 ก่อน (แล้วส่งช่องว่างเพื่อรักษาการเชื่อมต่อ) ดังนั้นความล้มเหลวที่เกิดขึ้นภายหลังจะถูกส่งกลับเป็น "200 พร้อมเนื้อหาข้อผิดพลาด": โปรดตรวจสอบอ็อบเจ็กต์ `error` ระดับบนสุด (เรายังเพิ่ม `"object": "error"` และ `"http_status"` ให้ด้วย) หากไคลเอนต์ของคุณมีเวลารอการอ่านนาน (OpenAI SDK ค่าเริ่มต้นคือ 10 นาที) ให้ส่ง `X-BazaarLink-Sync-Wait: 90` (วินาทีเต็ม 1–90 ค่าเริ่มต้น 20) เพื่อรับรหัสสถานะจริงสำหรับความล้มเหลวภายในเวลาดังกล่าว; ใน Python SDK ใช้ `default_headers={"X-BazaarLink-Sync-Wait": "90"}` ใน Node SDK ใช้ `defaultHeaders: { "X-BazaarLink-Sync-Wait": "90" }` บน Windows ให้ส่ง JSON จากไฟล์ UTF-8 ด้วย `curl --data-binary @body.json` เพราะข้อความที่พิมพ์หลัง `-d` ในคอนโซลไม่ใช่ UTF-8 และจะถูกปฏิเสธทันทีด้วย 400 `invalid_utf8`
A. /v1/chat/completions (native, แนะนำ) POST /v1/chat/completions
The canonical streaming path. Recommended for any new integration.
curl -N https://api.bazaarlink.ai/v1/chat/completions \
-H "Authorization: Bearer $BL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-image-2",
"messages": [{"role":"user","content":"a red cat on a sofa"}],
"modalities": ["image","text"],
"stream": true
}'
⌄ ดูทั้งหมด 9 บรรทัดImage-to-image: ใส่ส่วน image_url ในอาร์เรย์ content รองรับ data URI หรือ URL รูปภาพแบบ https (http:// จะถูกปฏิเสธ) สูงสุด 8 รูป ~10MB ต่อ data URI ข้อความที่แนบรูปต้องมีส่วนข้อความด้วย (คำสั่งแก้ไข) บางโมเดลยังรองรับ image_config (เช่น {"strength": 0.7}, 0–1 — ค่าต่ำกว่าจะใกล้เคียงรูปต้นฉบับมากกว่า) ซึ่งส่งต่อไปยัง upstream ตามเดิม
curl -N https://api.bazaarlink.ai/v1/chat/completions \
-H "Authorization: Bearer $BL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-image-2",
"messages": [{"role":"user","content":[
{"type":"image_url","image_url":{"url":"data:image/png;base64,..."}},
{"type":"text","text":"change the background to a night city"}
]}],
"modalities": ["image"],
"stream": true
}'
⌄ ดูทั้งหมด 12 บรรทัดแก้ไขรูปภาพ (เข้ากันได้กับ OpenAI) POST /v1/images/edits
client.images.edit() ของ OpenAI SDK ใช้งานได้ทันที (อัปโหลด multipart, ตอบกลับ JSON แบบซิงโครนัสคืนค่า data: [{ url }]) ข้อจำกัดเหมือน image-to-image: สูงสุด 8 รูป รูปละ 10MB ยังไม่รองรับ mask และ response_format=b64_json
curl https://api.bazaarlink.ai/v1/images/edits \
-H "Authorization: Bearer $BL_API_KEY " \
-F model="openai/gpt-5.4-image-2" \
-F image=@cat.png \
-F prompt="change the background to a night city" B. /v1/images/generations (รองรับ DALL·E) POST /v1/images/generations
OpenAI DALL-E request shape. Sync JSON ({ created, data: [{ url }] }) is the default and works with client.images.generate() out of the box; pass stream: true to get the SSE event stream documented below instead.
curl https://api.bazaarlink.ai/v1/images/generations \
-H "Authorization: Bearer $BL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-1",
"prompt": "a red cat on a sofa",
"size": "1024x1024"
}'
⌄ ดูทั้งหมด 8 บรรทัดmodelจำเป็น
string
ID โมเดล เช่น google/gemini-2.5-flash-image
promptจำเป็น
string
พรอมป์ข้อความ
size
string
ขนาดเอาต์พุต (แมปอัตโนมัติ)
n
integer
จำนวนรูป (ค่าเริ่มต้น 1)
curl -N https://api.bazaarlink.ai/v1/images/generations \
-H "Authorization: Bearer $BL_API_KEY " \
-H "Accept: text/event-stream" \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-5.4-image-2","prompt":"a red cat on a sofa","stream":true}' SSE event protocol ข้ามบรรทัดคอมเมนต์ SSE และ event unknown หรือ ping; จัดการ event image, usage และ done ที่ระบุไว้
: keep-alive
event: image
data: {"index": 0, "url": "https://api.bazaarlink.ai/v1/images/proxy/<token>"}
event: image-cached # bazaarlink Redis-backed proxy URL (1 hr TTL)
data: {"index": 0, "url": "https://api.bazaarlink.ai/v1/images/proxy/<token>"}
event: usage # final cost / token count
data: {"promptTokens": 12, "completionTokens": 7080, "cost": 0.226, "durationMs": 163400, "imageCount": 1}
event: done
data: {}
⌄ ดูทั้งหมด 13 บรรทัดโมเดลรูปภาพที่รองรับ Model ID Modality i2i (edits)
การสร้างวิดีโอ กระบวนการแบบอะซิงโครนัสสามขั้นตอน (submit → poll → content) การสร้างวิดีโอใช้เวลา 30 วินาที–5 นาที ซึ่งไม่เข้ากับความหมายของคำขอ/การตอบแบบซิงโครนัสของ chat-completions — ดังนั้น BazaarLink จึงแยกวิดีโอไปที่ endpoint เฉพาะ /v1/videos โดยใช้รูปแบบ job-id: submit จะได้ ID vjob_* → poll สถานะ → fetch bytes เมื่อเสร็จ การเรียกโมเดลวิดีโอผ่าน /chat/completions หรือ /images/generations จะได้ 400 (code: wrong_endpoint_for_video) ค่าใช้จ่ายจะชำระตาม usage.cost จริงเมื่อ completed
ประเภทงานวิดีโอ เอนด์พอยต์เดียวครอบคลุมหลายงาน งานใดจะทำงานขึ้นอยู่กับฟิลด์ที่คุณส่ง —— โมเดลเดียวสามารถทำ image-to-video, keyframes และการต่อวิดีโอได้ ไม่ใช่ทุกโมเดลจะรองรับทุกงาน คำขอที่ไม่รองรับจะคืนค่า 400
ข้อความเป็นวิดีโอ
prompt
สร้างจากพรอมป์ตข้อความเพียงอย่างเดียว — ไม่ต้องมีสื่ออินพุต
ภาพเป็นวิดีโอ
frame_images: [ first frame ]
ภาพของคุณคือภาพนั้นเอง: กลายเป็นเฟรมแรกแล้วถูกทำให้เคลื่อนไหว โดยยังคงซื่อตรงต่อภาพต้นฉบับ เช่น ภาพถ่ายแมว → แมวตัวเดิมหันหัวในฉากเดิม
คีย์เฟรม (แรก + สุดท้าย)
frame_images: [ first, last ]
ให้ภาพเริ่มต้นและภาพสุดท้าย โมเดลจะแทรกการเคลื่อนไหวระหว่างทั้งสอง
การต่อวิดีโอ
input_video
ต่อคลิปที่มีอยู่ duration ที่ขอต้องมากกว่าความยาวของวิดีโอต้นฉบับ
อ้างอิงเป็นวิดีโอ
input_references: [ images ]
ภาพของคุณเป็นภาพอ้างอิง ไม่ใช่เฟรม: โมเดลคงวัตถุ/สไตล์ไว้และสร้างฉากใหม่ทั้งหมด เช่น ภาพแมว + "เต้นในป่า" → วิดีโอใหม่ที่คงหน้าตาของแมวไว้แต่ฉากและการเคลื่อนไหวเป็นของใหม่ (1–9 ภาพอ้างอิง) ต่างจากภาพเป็นวิดีโอ: i2v ซื่อตรงต่อภาพต้นฉบับที่แน่นอน ส่วน r2v นำวัตถุมาแสดงใหม่ในฟุตเทจใหม่
แก้ไขวิดีโอ
input_video + prompt
แก้ไขวิดีโอที่มีอยู่ — เปลี่ยนฉาก สไตล์ หรือการเคลื่อนไหว คิดเงินตามวินาทีวิดีโออินพุต + วินาทีเอาต์พุต
1. ส่งงาน (คืน vjob_xxx ทันที) POST /v1/videos
modelจำเป็น
string
ID โมเดล เช่น bytedance/seedance-2.0
promptจำเป็น
string
พรอมป์ข้อความ
duration
integer
ระยะเวลาเป็นวินาที (ขึ้นกับโมเดล)
resolution
string
ความละเอียด — 480p / 720p / 1080p ฯลฯ
generate_audio
boolean
สร้างแทร็กเสียง (true/false)
frame_images
array
ภาพเฟรมแรก/สุดท้าย (image-to-video, keyframes) อ็อบเจ็กต์ { type: "image_url", image_url: { url }, frame_type: "first_frame" | "last_frame" } หรือสตริง URL ธรรมดา
input_references
array
ภาพอ้างอิงสำหรับ reference-to-video —— ชี้นำวัตถุ/สไตล์ ไม่ใช่เฟรมที่แม่นยำ
input_video
string|object
URL วิดีโอต้นฉบับสำหรับการต่อวิดีโอและการแก้ไขวิดีโอ ต้องให้ upstream เข้าถึงได้แบบสาธารณะ
aspect_ratio
string
อัตราส่วนภาพ เช่น 16:9 หรือ 9:16 จะถูกละเว้นเมื่อภาพอินพุตกำหนดอัตราส่วน
watermark
boolean
เพิ่มลายน้ำ ค่าเริ่มต้น false
callback_url
string
URL webhook ที่ถูกเรียกเมื่องานถึงสถานะสุดท้าย — เฉพาะ HTTPS มีการตรวจสอบ SSRF ไม่มีลายเซ็นใน v1 ให้ถือเป็นคำใบ้และยืนยันผ่าน GET /videos/{id}
curl https://api.bazaarlink.ai/v1/videos \
-H "Authorization: Bearer $BL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "bytedance/seedance-2.0",
"prompt": "a bird flying over mountains",
"duration": 3,
"resolution": "720p",
"generate_audio": false
}'
⌄ ดูทั้งหมด 11 บรรทัดNote
เมื่อ submit จะสำรองเครดิตตามประมาณการกรณีเลวร้ายที่สุด เมื่อ job เสร็จ usage.cost คือจำนวน USD ที่เรียกเก็บจากลูกค้าสำหรับคำขอนั้น
2. Poll สถานะ GET /v1/videos/{id}
curl -H "Authorization: Bearer $BL_API_KEY " \
https://api.bazaarlink.ai/v1/videos/vjob_xxxNote
แต่ละ GET ต้องห่างกัน ≥ 8 วินาทีจึงจะส่งไปยัง upstream จริง (หลีกเลี่ยง rate limit)
Note
เมื่อ status=failed จะคืนยอดที่กันไว้ทั้งหมดให้ผู้ใช้
3. ดึงเนื้อหาวิดีโอ (MP4) GET /v1/videos/{id}/content
curl -H "Authorization: Bearer $BL_API_KEY " \
-o output.mp4 \
https://api.bazaarlink.ai/v1/videos/vjob_xxx/contentสิ่งที่ควรรู้ ความละเอียดที่อนุญาตต่างกันในแต่ละโมเดล —— ค่าที่ไม่รองรับจะคืนค่า 400 พร้อมรายการที่รองรับ ภาพ/วิดีโออินพุตต้องเข้าถึงได้จาก URL สาธารณะ โฮสต์ที่ป้องกัน hotlink (เช่น wiki บางแห่ง) จะล้มเหลว สื่ออินพุตจะผ่านการตรวจสอบเนื้อหาของ upstream และบางครั้งอาจถูกปฏิเสธ สำหรับการต่อวิดีโอ duration ที่ขอต้องมากกว่าความยาววิดีโอต้นฉบับ อัตราส่วนภาพเอาต์พุตจะเป็นไปตามภาพอินพุต —— ภาพสี่เหลี่ยมจัตุรัสให้วิดีโอสี่เหลี่ยมจัตุรัส การแก้ไขวิดีโอคิดเงินตามวินาทีของวิดีโออินพุตบวกวินาทีของเอาต์พุตที่สร้างขึ้น input_video (การแก้ไข / การต่อวิดีโอ) ต้องเป็น URL สาธารณะ วิดีโอที่คุณสร้างที่นี่ถูกให้บริการหลัง API key ของคุณ upstream จึงดึงไม่ได้ —— โฮสต์วิดีโอต้นฉบับของคุณไว้บน URL ที่เข้าถึงได้สาธารณะ Payload ของ webhook ไม่มีลายเซ็น — ยืนยันสถานะ/จำนวนเงินผ่าน GET /videos/{id} ก่อนดำเนินการ และสังเกตว่า unsigned_urls ที่นั่นเป็นแบบสัมบูรณ์ (ต่างจาก path แบบสัมพัทธ์ในการตอบกลับ poll) โมเดลวิดีโอที่รองรับ Model ID Modality Tasks minimax/hailuo-3-max text+image->video t2v, i2v google/veo-3.1 text+image->video t2v, i2v bytedance/seedance-2.5 text+image+audio+video->video — x-ai/grok-imagine-video-1.5-lite text+image->video t2v, i2v bytedance/seedance-2.0 text+image+audio+video->video t2v, i2v bytedance/seedance-1-5-pro text+image->video t2v, i2v bytedance/seedance-2.0-fast text+image+audio+video->video t2v, i2v
สังเคราะห์เสียงพูด แปลงข้อความเป็นเสียงด้วยรหัสโมเดลจาก /v1/models?output_modalities=speech คิดราคาต่อล้านอักขระตามหน้าโมเดล ระบบจะบัฟเฟอร์เสียงทั้งหมดก่อนส่งคืนเป็นข้อมูลไบนารี ยังไม่รองรับการสตรีมทีละช่วง ฟิลด์ควบคุมการกำหนดเส้นทาง เช่น provider, transforms, route, service_tier และ preset จะถูกละเว้น
POST /v1/audio/speech
curl https://api.bazaarlink.ai/v1/audio/speech \
-H "$BAZAARLINK_AUTH_HEADER " \
-H "Content-Type: application/json" \
-d '{"model":"<speech-model-id>","input":"Hello","voice":"alloy","response_format":"mp3"}' \
--output speech.mp3
curl -D - https://api.bazaarlink.ai/v1/audio/speech \
-H "$BAZAARLINK_AUTH_HEADER " \
-H "Content-Type: application/json" \
-d '{"model":"elevenlabs/eleven-v4","input":"Hello","voice":"george","stability":0.4,"similarity_boost":0.8,"style":0.2,"use_speaker_boost":true,"language_code":"en","audio_effects":{"distance":0.3}}' \
--output speech.mp3
⌄ ดูทั้งหมด 12 บรรทัดถอดเสียง ส่ง multipart/form-data model และ file หรือ JSON model และ input_audio:{data,format} (base64 ดิบ) รูปแบบ wav, mp3, mp4, m4a, ogg, flac, webm, aac เสียงสูงสุด 25 MiB; เนื้อหาคำขอ 50 MiB ค่า audio.transcription_max_seconds_by_model กำหนดขีดจำกัดตามโมเดล หากไม่มีจะใช้ audio.transcription_max_seconds แล้วจึงใช้ค่าเริ่มต้น 60 วินาที เสียงที่ยาวกว่าจะถูกปฏิเสธก่อนประมวลผลด้วย 413 audio_too_long และไม่คิดค่าบริการ response_format เฉพาะ json หรือ verbose_json; timestamp_granularities word/segment ต้องใช้ verbose_json ไม่รองรับ stream (400 unsupported_parameter); ใหญ่เกินไป 413 audio_too_large ละเว้น provider คิดค่าบริการตามราคาฐานข้อมูลต่อ usage.seconds หรือ token ขาเข้า/ขาออก ราคานาที = 60 × ราคาวินาที usage.cost เป็นค่าบริการลูกค้าใน USD
POST /v1/audio/transcriptions
curl https://api.bazaarlink.ai/v1/audio/transcriptions \
-H "$BAZAARLINK_AUTH_HEADER " \
-F model="<transcription-model-id>" \
-F file=@audio.wav \
-F response_format=json
curl https://api.bazaarlink.ai/v1/audio/transcriptions \
-H "$BAZAARLINK_AUTH_HEADER " \
-H "Content-Type: application/json" \
-d '{"model":"<transcription-model-id>","input_audio":{"data":"<raw-base64-audio>","format":"wav"},"response_format":"verbose_json","timestamp_granularities":["word","segment"]}'
⌄ ดูทั้งหมด 10 บรรทัดจัดอันดับเอกสารใหม่ ส่ง query และ documents เพื่อรับ index และ relevance_score ที่เรียงแล้ว หน่วยคิดค่าบริการคือ search ใช้ราคาหน้าโมเดลคูณ usage.search_units ไม่ใช่จำนวนเอกสาร ไม่รองรับการสตรีม (stream)
POST /v1/rerank
curl https://api.bazaarlink.ai/v1/rerank \
-H "$BAZAARLINK_AUTH_HEADER " \
-H "Content-Type: application/json" \
-d '{"model":"your-rerank-model-id","query":"capital of France","documents":["Paris is the capital of France.","Berlin is in Germany."],"top_n":1}' POST /v1/chat/completions
ใช้ audio หรือ input_audio กับ /v1/chat/completions และโมเดลที่รองรับเสียง ราคาโทเคนอินพุตและเอาต์พุตที่ตั้งค่าไว้ใช้ร่วมกันกับโทเคนข้อความและเสียงทั้งหมดที่รายงาน
curl https://api.bazaarlink.ai/v1/chat/completions \
-H "$BAZAARLINK_AUTH_HEADER " \
-H "Content-Type: application/json" \
-d '{"model":"<audio-chat-model-id>","messages":[{"role":"user","content":"Say hi."}],"stream":true,"modalities":["text","audio"],"audio":{"voice":"alloy","format":"pcm16"},"max_tokens":32}' คู่มือสังเคราะห์เสียงพูด (TTS) POST /v1/audio/speech รองรับรูปแบบ OpenAI-compatible: ส่ง JSON แล้วรับไฟล์เสียงเป็นข้อมูลไบนารี กลุ่ม ElevenLabs มี elevenlabs/eleven-v4, eleven-v4-turbo, eleven-v3, eleven-v3-conversational, eleven-multilingual-v2, eleven-flash-v2.5, eleven-flash-v2, eleven-turbo-v2.5, eleven-turbo-v2 ดูรายการล่าสุดที่ GET /v1/models?output_modalities=speech GET /v1/models ค่าเริ่มต้นจะคืนเฉพาะโมเดลข้อความ ให้เพิ่ม ?output_modalities=speech (หรือ all) เพื่อดูรายการ
POST /v1/audio/speech
พารามิเตอร์ พารามิเตอร์ ชนิด จำเป็น คำอธิบาย model string ใช่ รหัสโมเดลเสียงพูด เช่น elevenlabs/eleven-flash-v2.5 input string ใช่ ข้อความที่จะสังเคราะห์: สูงสุด 4,096 อักขระต่อคำขอ (10,000 สำหรับ elevenlabs/eleven-v4 และ eleven-v4-turbo) หากยาวกว่านั้นให้แบ่งเป็นหลายคำขอ voice string ใช่ เสียงที่จะใช้ รูปแบบขึ้นอยู่กับโมเดล ดูกฎการใช้เสียงด้านล่าง response_format string ไม่ mp3 (ค่าเริ่มต้น) หรือ pcm API รับ opus, aac, flac และ wav แต่โมเดล ElevenLabs ปฏิเสธด้วย 400 ในขณะนี้ speed number ไม่ ความเร็วเสียงพูดตั้งแต่ 0.25 ถึง 4.0 ไม่ใช่ทุกโมเดลจะนำไปใช้ instructions string ไม่ คำสั่งกำหนดสไตล์เสียง ไม่ใช่ทุกโมเดลจะนำไปใช้ stability number ไม่ ความคงที่ของเสียง 0–1 (ค่าเริ่มต้น 0.5) ยิ่งต่ำยิ่งมีอารมณ์ ยิ่งสูงยิ่งเรียบ มีผลกับโมเดล elevenlabs/* เมื่อคำขอถูกให้บริการผ่านเส้นทางเสียงโดยตรงของเรา เฮดเดอร์ตอบกลับ X-Voice-Settings จะบอกว่า applied หรือ ignored similarity_boost number ไม่ ความคล้ายกับเสียงต้นฉบับ 0–1 (ค่าเริ่มต้น 0.75) Eleven v3 ไม่ใช้ค่านี้ style number ไม่ ความเน้นสไตล์ 0–1 (ค่าเริ่มต้น 0) ค่าเกิน 0 ทำให้ล่าช้าขึ้น Eleven v4 ไม่ใช้ค่านี้ use_speaker_boost boolean ไม่ เพิ่มความคล้ายกับผู้พูดต้นฉบับ (ค่าเริ่มต้น true) ทำให้ล่าช้าเล็กน้อย clone_strength number ไม่ ความแรงของการโคลน 0–1 (แนะนำ 0 สำหรับเสียงส่วนใหญ่) ใช้ได้เฉพาะเสียงโคลนระดับมืออาชีพของคุณเอง (voice_…) ที่ฝึกสำหรับ Eleven v4 language_code string ไม่ รหัสภาษาตัวพิมพ์เล็กสองตัวอักษร (ISO 639-1) เช่น ar, ja, en เพื่อกำหนดภาษาที่อ่าน โมเดล multilingual-v2 ไม่ใช้ค่านี้ audio_effects object ไม่ ออบเจ็กต์เอฟเฟกต์เสียงแบบเลือกได้: filter_preset_id (ฟิลเตอร์ เช่น phone, old_radio), environment_id (พื้นที่เสียงก้อง เช่น small_room, hall), background_noise_id (เช่น cafe), distance (0–1), send_level (ปริมาณเสียงก้อง 0–1) และ pan (−1…1) ID ใช้ตัวพิมพ์เล็ก ตัวเลข และขีดล่างเท่านั้น ไม่คิดค่าบริการเพิ่ม เสียงก้องหรือ pan ที่ไม่เท่ากับ 0 จะได้เสียงสเตอริโอ และใช้ร่วมกับเอาต์พุต pcm ไม่ได้
การตั้งค่าเสียงทั้งเจ็ดข้างบนเป็นตัวเลือกทั้งหมด หากไม่ส่งก็ไม่มีอะไรเปลี่ยน ค่านอกช่วงจะได้ 400 และจะไม่ถูกส่งหรือคิดเงิน เฮดเดอร์ตอบกลับ X-Voice-Settings บอกว่าการตั้งค่าของคุณถูกใช้หรือไม่: applied = ใช้แล้ว; ignored = เส้นทางสำรองตอบกลับ จึงไม่ได้ใช้การตั้งค่าของคุณ (ยังสร้างเสียงได้ตามปกติ); ไม่มีเฮดเดอร์ = คุณไม่ได้ส่งการตั้งค่าเสียง ตัวอย่าง: stability 0 อ่านมีอารมณ์มากขึ้น 1 อ่านเรียบขึ้น
กฎการใช้เสียง โมเดล ElevenLabs (elevenlabs/…) รับชื่อเสียงต่อไปนี้ชื่อใดชื่อหนึ่ง (ไม่แยกตัวพิมพ์เล็กใหญ่): george, sarah, adam, alice, bella, bill, brian, callum, charlie, chris, daniel, eric, harry, jessica, laura, liam, lily, matilda, river, roger, will โมเดล ElevenLabs เว้น voice ได้ (ค่าเริ่มต้น george) ค่าอื่นจะได้ 400 invalid_voice เสียงที่กำหนดเองของคุณ (voice_…) อธิบายไว้ในหัวข้อ เสียงที่กำหนดเอง ด้านล่าง
ชื่อเสียงแบบ OpenAI-style เช่น alloy, echo หรือ nova ใช้ได้เฉพาะโมเดลที่ระบุชื่อเหล่านี้ ตรวจสอบเสียงในหน้าโมเดล
เสียงที่กำหนดเอง (โคลน) กำลังเปิดให้ใช้เป็นขั้นตอน: ดูหัวข้อ «เสียงที่กำหนดเอง» ด้านล่าง (POST /v1/voices) จนกว่าจะเปิดให้บัญชีของคุณ ให้ใช้ชื่อพรีเซ็ต 21 ชื่อด้านบนหรือ voice ID สาธารณะ
ส่ง alloy ให้โมเดล ElevenLabs แล้วจะล้มเหลว
หากโมเดล ElevenLabs ได้รับเสียงที่ไม่ใช่ voice ID และไม่ใช่ชื่อที่รองรับ (เช่น alloy หรือ Rachel) จะตอบ 400 invalid_voice และข้อความจะแสดงชื่อที่ยอมรับ คำขอที่ล้มเหลวไม่ถูกเรียกเก็บเงิน
รายการเสียงที่มีให้ ตั้งค่า voice เป็นชื่อใดชื่อหนึ่งด้านล่าง (ตัวพิมพ์เล็ก) แต่ละเสียงมีคลิปตัวอย่างสั้น ๆ ของเราเอง และ GET /api/v1/audio/voices จะคืนรายการทั้งหมด (เพศ ช่วงอายุ สำเนียง สไตล์ และ URL ตัวอย่าง)
?lang= (en, zh-TW, zh-CN; ค่าเริ่มต้นตาม Accept-Language) กำหนดเฉพาะภาษาของ description ส่วน URL ตัวอย่างไม่เปลี่ยนตามพารามิเตอร์: preview_urls.en (เหมือน preview_url) คือคลิปภาษาอังกฤษ และ preview_urls.zh (เหมือน preview_url_zh) คือคลิปภาษาจีน
เสียง คำอธิบาย ฟังตัวอย่าง george Male, middle-aged, British accent. Mature and steady, suited to narration and storytelling. sarah Female, young adult, American accent. Professional and clear, suited to broadcast-style reading. adam Male, middle-aged, American accent. Everyday and approachable, suited to short social videos. alice Female, middle-aged, British accent. Professional and informative, suited to explainers and teaching. bella Female, middle-aged, American accent. Professional and informative, suited to explainers and teaching. bill Male, senior, American accent. Crisp and direct, suited to advertising voice-overs. brian Male, middle-aged, American accent. Polished and refined, suited to social and brand content. callum Male, middle-aged, American accent. Expressive, suited to characters and animation. charlie Male, young adult, Australian accent. Energetic and lively, suited to conversation. chris Male, middle-aged, American accent. Relaxed and casual, suited to conversation. daniel Male, middle-aged, British accent. Formal and measured, suited to news-style and educational reading. eric Male, middle-aged, American accent. Polished and warm, suited to conversation. harry Male, young adult, American accent. Rough and gritty, suited to character voices. jessica Female, young adult, American accent. Bright and cute, suited to conversation. laura Female, young adult, American accent. Playful with attitude, suited to social content. liam Male, young adult, American accent. Confident and upbeat, suited to social content. lily Female, middle-aged, British accent. Confident and clear, suited to explainers and teaching. matilda Female, middle-aged, American accent. Upbeat and friendly, suited to explainers and teaching. river Neutral voice, middle-aged, American accent. Calm and even, suited to conversation. roger Male, middle-aged, American accent. Polished and confident, suited to conversation. will Male, young adult, American accent. Laid-back and easygoing, suited to conversation.
แท็กอารมณ์และท่าทาง (audio tags) เขียนแท็กในวงเล็บเหลี่ยมไว้ใน input ได้โดยตรง เช่น [laughs], [whispers], [excited], [sighs], [crying], [curious] หรือ [softly] แท็กจะถูกส่งให้โมเดลตามที่พิมพ์ทุกประการ และกำหนดวิธีแสดงถ้อยคำที่ตามมา แม้ข้อความจะเป็นภาษาไทย ให้คงแท็กเป็นภาษาอังกฤษ
curl https://api.bazaarlink.ai/v1/audio/speech \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{"model":"elevenlabs/eleven-v3","input":"[laughs] That was actually funny. [whispers] Do not tell anyone.","voice":"george","response_format":"mp3"}' \
--output audio-tags.mp3รองรับโดย elevenlabs/eleven-v3 และกลุ่ม elevenlabs/eleven-v4 โมเดลเสียงอื่นไม่ตีความแท็กและอาจอ่านข้อความในวงเล็บออกเสียง ควรลองกับประโยคสั้น ๆ ก่อน
แท็กนับเป็นอักขระของ input และคิดเงินเหมือนข้อความส่วนอื่น
รูปแบบผลลัพธ์ หากไม่ใส่ response_format ค่าเริ่มต้นคือ mp3 (Content-Type audio/mpeg) และ pcm (audio/pcm, PCM 16 บิตดิบ) ก็ใช้ได้ API รับ opus, aac, flac และ wav แต่โมเดล ElevenLabs ปฏิเสธด้วย 400 ในขณะนี้ บันทึกไฟล์ตามส่วนหัว Content-Type ของการตอบกลับ
การคิดค่าบริการ การสังเคราะห์เสียงคิดตามจำนวนอักขระอินพุต ราคาต่ออักขระอยู่ในหน้าโมเดลที่ /models และใน GET /v1/models ที่ pricing.character หน้าโมเดลแสดงราคาต่อล้านอักขระ
ตัวอย่าง cURL Python JavaScript
curl https://api.bazaarlink.ai/v1/audio/speech \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{"model":"elevenlabs/eleven-flash-v2.5","input":"Hello from BazaarLink.","voice":"george","response_format":"mp3"}' \
--output speech.mp3ข้อผิดพลาดที่พบบ่อย สถานะ สาเหตุและวิธีแก้ 400 คำขอไม่ถูกต้อง: ขาด model, input หรือ voice; input เกิน 4,096 อักขระ; speed อยู่นอก 0.25–4.0; response_format ไม่รองรับ; Unknown voice; unknown_model (ตรวจสอบ ID ที่ /models) 401 ไม่มีคีย์ API หรือคีย์ไม่ถูกต้อง ส่ง Authorization: Bearer พร้อมคีย์ BazaarLink 402 ยอดคงเหลือไม่พอ เติมเงินแล้วลองใหม่ 403 คีย์จัดการเรียกโมเดลไม่ได้ หรือบัญชีถูกระงับ ใช้คีย์ API ปกติ 429 ถึงขีดจำกัดอัตราแล้ว รอตาม Retry-After แล้วลองใหม่ 502 บริการโมเดลไม่พร้อมชั่วคราวหรือการส่งเสียงขาดตอน ลองใหม่ คำขอที่ล้มเหลวไม่คิดค่าบริการ
ข้อมูลพารามิเตอร์ทั้งหมด: สังเคราะห์เสียงพูด
คู่มือถอดเสียงเป็นข้อความ POST /v1/audio/transcriptions รองรับรูปแบบ OpenAI-compatible: อัปโหลดเสียงด้วย multipart/form-data หรือส่ง input_audio แบบ base64 ผ่าน JSON แล้วรับข้อความ โมเดลมี elevenlabs/scribe-v2 และ elevenlabs/scribe-v2-medical ดูรายการล่าสุดที่ GET /v1/models?output_modalities=transcription GET /v1/models ค่าเริ่มต้นจะคืนเฉพาะโมเดลข้อความ ให้เพิ่ม ?output_modalities=transcription (หรือ all) เพื่อดูรายการ
POST /v1/audio/transcriptions
พารามิเตอร์ พารามิเตอร์ ชนิด จำเป็น คำอธิบาย model string ใช่ รหัสโมเดลถอดเสียง เช่น elevenlabs/scribe-v2 file file ใช่ ไฟล์เสียง (multipart) รองรับ wav, mp3, mp4, m4a, ogg, flac, webm, aac สูงสุด 25 MiB ไคลเอนต์ JSON ใช้ input_audio: {data: base64, format} แทนได้ response_format string ไม่ json (ค่าเริ่มต้น) ส่งคืน {text}; verbose_json เพิ่มภาษา ระยะเวลา และ segments/words language string ไม่ คำใบ้ภาษาแบบเลือกได้ เช่น en หรือ zh เว้นว่างเพื่อให้ตรวจจับอัตโนมัติ prompt string ไม่ ข้อความบริบทแบบเลือกได้เพื่อช่วยจำชื่อและศัพท์ ไม่ใช่ทุกโมเดลจะนำไปใช้ timestamp_granularities[] string[] ไม่ word และ/หรือ segment ใช้เฉพาะเมื่อ response_format=verbose_json; รูปแบบอื่นจะละเว้น ขณะนี้ยังไม่ส่งคืนเวลาระดับคำ แต่ส่งคืน segments
รูปแบบผลลัพธ์ response_format รับเฉพาะ json หรือ verbose_json (ไม่รองรับ text, srt, vtt) ไม่รองรับ stream ระยะเวลาเสียงจำกัดตามโมเดล ค่าเริ่มต้น 60 วินาที เสียงที่ยาวกว่าจะถูกปฏิเสธก่อนประมวลผลด้วย 413 audio_too_long และไม่คิดค่าบริการ ให้แบ่งเสียงยาวเป็นช่วง
การคิดค่าบริการ การถอดเสียงคิดตามจำนวนวินาทีของเสียง ราคาต่อวินาทีอยู่ในหน้าโมเดลที่ /models และใน GET /v1/models ที่ pricing.second; ราคาต่อนาทีเท่ากับ 60 เท่าของค่านี้ คำตอบ usage แสดงวินาทีที่คิดเงิน และ usage.cost แสดงยอดเรียกเก็บ
ตัวอย่าง cURL Python JavaScript
curl https://api.bazaarlink.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-F model="elevenlabs/scribe-v2" \
-F file=@audio.mp3 \
-F response_format=verbose_json \
-F "timestamp_granularities[]=word" ข้อผิดพลาดที่พบบ่อย สถานะ สาเหตุและวิธีแก้ 400 คำขอไม่ถูกต้อง: ขาด model หรือ file, เสียงว่าง, response_format ไม่ใช่ json/verbose_json, stream=true (unsupported_parameter) หรือ timestamp_granularities ไม่ใช่ word/segment 401 ไม่มีคีย์ API หรือคีย์ไม่ถูกต้อง 402 ยอดคงเหลือไม่พอ เติมเงินแล้วลองใหม่ 413 audio_too_large: เสียงหลังถอดรหัสเกิน 25 MiB audio_too_long: เสียงเกินขีดจำกัดตามโมเดล (ค่าเริ่มต้น 60 วินาที) จะถูกปฏิเสธก่อนประมวลผลและไม่คิดค่าบริการ ให้บีบอัดหรือแบ่งเสียง 429 ถึงขีดจำกัดอัตราแล้ว รอตาม Retry-After แล้วลองใหม่ 502 บริการโมเดลไม่พร้อมชั่วคราวหรือการส่งเสียงถูกขัดจังหวะ ให้ลองใหม่ คำขอที่ล้มเหลวไม่คิดค่าบริการ
ข้อมูลพารามิเตอร์ทั้งหมด: ถอดเสียง
เสียงที่กำหนดเอง (การโคลนเสียง) เสียงที่กำหนดเอง (การโคลนเสียง)
เปิดให้ใช้เฉพาะผู้ที่ยื่นขอ เสียงที่กำหนดเองเปิดทีละบัญชี: ติดต่อฝ่ายสนับสนุนลูกค้าเพื่อขอใช้ จนกว่าบัญชีของคุณจะเปิดใช้งาน ทุกคำขอ /v1/voices จะตอบ 403 voice_cloning_not_enabled (และ 404 not_found ขณะที่ฟีเจอร์ปิดสำหรับทุกคน) ขีดจำกัดและราคาในหน้านี้เป็นค่าเริ่มต้นและอาจเปลี่ยนแปลงได้
อัปโหลดคลิปเสียงสั้น ๆ ของเสียงที่คุณมีสิทธิ์ใช้ แล้วคุณจะได้ voice id ของเรา (voice_…) ส่ง id นั้นเป็น voice ของ POST /v1/audio/speech เสียงนี้ใช้ได้เฉพาะผู้ที่สร้างเท่านั้น
เอนด์พอยต์ POST /v1/voices
สร้างเสียง (multipart/form-data)
GET /v1/voices
แสดงรายการเสียงของคุณ (limit 1–100, after = voice id สำหรับหน้าถัดไป)
GET /v1/voices/{id}
ดูเสียงของคุณหนึ่งรายการ
DELETE /v1/voices/{id}
ลบเสียง (มีผลทันที)
POST /v1/voices/report
รายงานเสียง (ไม่ต้องใช้ API key)
การสร้างเสียง: ฟิลด์ ฟิลด์ ชนิด จำเป็น คำอธิบาย name string ใช่ ชื่อเสียง 1–60 ตัวอักษร files file[] ใช่ ไฟล์บันทึกเสียงของเสียงนั้น 1 ถึง 5 ไฟล์ (mp3, wav, m4a, ogg, flac, webm) consent boolean ใช่ ต้องเป็น true: คุณยืนยันว่ามีสิทธิ์โคลนและใช้เสียงนี้ (ดู "ความยินยอม") consent_statement_version string ใช่ เวอร์ชันของคำแถลงความยินยอมที่คุณยืนยัน ปัจจุบันคือ "v1" description string ไม่ ไม่บังคับ ไม่เกิน 200 ตัวอักษร remove_background_noise boolean ไม่ บูลีนไม่บังคับ ค่าเริ่มต้น false ลดเสียงรบกวนพื้นหลังในตัวอย่างก่อนโคลน
คำขอเป็นแบบซิงโครนัส: เมื่อได้ 201 แสดงว่าเสียงพร้อมใช้งาน ส่งเฮดเดอร์ Idempotency-Key (สตริงที่ไม่ซ้ำอะไรก็ได้) และใช้ค่าเดิมเมื่อลองใหม่ เพื่อให้การลองใหม่ไม่สร้างหรือเก็บเงินเสียงที่สอง
การตอบกลับ 201 พร้อม id (voice_…), object ("voice"), name, description, status ("ready"), created_at (วินาที Unix) และ usage.cost_usd (ค่าสร้างที่เรียกเก็บ) ข้อมูลอื่นเกี่ยวกับวิธีสร้างเสียงจะไม่ออกนอกระบบของเรา
GET /v1/voices ส่งคืนเฉพาะเสียงของคุณเอง: { "object": "list", "data": [ … ], "has_more": false } voice id ของผู้อื่นจะตอบ 404 voice_not_found เหมือนกับ id ที่ไม่มีอยู่
GET /v1/voices/{id} ส่งคืนเสียงหนึ่งรายการ (ฟิลด์เหมือนข้างต้น ไม่มี usage)
DELETE /v1/voices/{id} ส่งคืน { "id": "voice_…", "object": "voice", "deleted": true } และมีผลทันที: คำขอ speech ที่ใช้เสียงนั้นจะล้มเหลวทันที การลบไม่มีค่าใช้จ่าย และค่าสร้างไม่คืนเงิน
ขีดจำกัด (ค่าเริ่มต้น) ไม่เกิน 3 เสียงต่อคน ไฟล์เสียง 1 ถึง 5 ไฟล์ต่อเสียง ไฟล์ละไม่เกิน 10 MB และรวมไม่เกิน 25 MB รูปแบบ: mp3, wav, m4a, ogg, flac, webm เสียงพูดที่ชัดเจนรวมประมาณ 30 วินาทีถึง 5 นาทีให้ผลดีที่สุด สร้างได้ไม่เกิน 3 ครั้งต่อวัน (วัน UTC) บัญชีของคุณต้องยืนยันอีเมลแล้วและมียอดคงเหลืออย่างน้อย US$5 ชื่อและคำอธิบายที่เลียนแบบบุคคลสาธารณะ หรือฟังดูเหมือนเสียงทางการหรือพนักงาน จะถูกปฏิเสธ (invalid_voice_name) ไฟล์บันทึกเสียงใช้เพื่อสร้างเสียงเท่านั้นและเราไม่เก็บไว้ เราเก็บเฉพาะชื่อเสียง เจ้าของ บันทึกความยินยอม และเวลา ราคา การสร้างเสียงมีค่าธรรมเนียมครั้งเดียว (ค่าเริ่มต้น US$1.00) จำนวนที่เรียกเก็บส่งคืนใน usage.cost_usd และจะเรียกเก็บเมื่อสร้างเสียงสำเร็จเท่านั้น การใช้เสียงที่กำหนดเองกับ speech คิดราคาต่อตัวอักษรเท่ากับเสียงอื่นของโมเดลนั้น การลบไม่มีค่าใช้จ่าย
ความยินยอม ทุกการสร้างต้องส่ง consent=true และ consent_statement_version="v1" หากมีการอัปเดตคำแถลง การสร้างจะตอบ 400 consent_version_mismatch และคุณต้องยืนยันใหม่ด้วยเวอร์ชันใหม่
ร่างคำแถลงที่คุณยืนยัน (ถ้อยคำสุดท้ายอยู่ระหว่างตรวจสอบและอาจเปลี่ยนแปลง):
I confirm that I own the voice in these recordings or have the written permission of the person whose voice it is, that this person is an adult and has agreed to have their voice cloned and synthesized, and that I will not use the voice to impersonate a real person, to deceive, to harass, or for political persuasion, fraud or any unlawful purpose. I understand the voice can be removed and my account suspended if I break these rules. ใช้เสียงที่กำหนดเอง ส่ง voice id เป็น voice ของ POST /v1/audio/speech (voice=voice_…) คู่กับโมเดลเสียงในตระกูล elevenlabs/* ขีดจำกัดอินพุต รูปแบบ และราคาต่อตัวอักษรเป็นของโมเดลนั้น voice id ที่ไม่มีอยู่ ถูกลบหรือถูกบล็อก หรือเป็นของผู้อื่น จะตอบ 400 invalid_voice และเสียงที่กำหนดเองใช้กับโมเดลอื่นไม่ได้
ตัวอย่าง cURL Python JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
curl https://api.bazaarlink.ai/v1/voices \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Idempotency-Key: $(uuidgen) " \
-F name="My narrator" \
-F description="Warm and calm" \
-F consent=true \
-F consent_statement_version=v1 \
-F files=@sample-1.mp3 \
-F files=@sample-2.wav
curl "https://api.bazaarlink.ai/v1/voices?limit=20" \
-H "Authorization: Bearer $BAZAARLINK_API_KEY "
curl -X DELETE https://api.bazaarlink.ai/v1/voices/voice_0123456789abcdef01234567 \
-H "Authorization: Bearer $BAZAARLINK_API_KEY "
curl https://api.bazaarlink.ai/v1/audio/speech \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{"model":"elevenlabs/eleven-flash-v2.5","input":"Hello, this is my own voice.","voice":"voice_0123456789abcdef01234567","response_format":"mp3"}' \
--output my-voice.mp3
⌄ ดูทั้งหมด 21 บรรทัดรายงานเสียง หากมีเสียงเลียนแบบคุณหรือผู้อื่นโดยไม่ได้รับอนุญาต โปรดรายงาน: POST /v1/voices/report (ไม่ต้องใช้ API key) ด้วย JSON ที่มี voice_id (voice_…) หรือ sample_url, reason (impersonation, fraud, harassment, minor, political หรือ other) และไม่บังคับ details กับ contact (อีเมล) ตอบ 202 เสมอ เราตรวจสอบรายงานและลบเสียงที่ละเมิดกฎ บัญชีอาจถูกระงับ
curl https://api.bazaarlink.ai/v1/voices/report \
-H "Content-Type: application/json" \
-d '{"voice_id":"voice_0123456789abcdef01234567","reason":"impersonation","details":"...","contact":"me@example.com"}' การใช้อย่างรับผิดชอบ อย่าโคลนเสียงของบุคคลสาธารณะ คนดัง นักการเมือง หรือผู้ที่ไม่ได้ยินยอม อย่าใช้เสียงโคลนเพื่อทำให้ผู้คนเชื่อว่ากำลังคุยกับตัวจริง เพื่อหลอกลวง คุกคาม โน้มน้าวทางการเมือง หรือฉ้อโกง
ข้อผิดพลาด สถานะ รหัส ความหมาย 400 bad_request คำขอรูปแบบไม่ถูกต้อง: ไม่ใช่ multipart/form-data ไม่มีไฟล์เสียง description ยาวเกินไป หรือ limit อยู่นอกช่วง 1–100 400 consent_required ไม่มี consent=true 400 consent_version_mismatch เวอร์ชันคำแถลงความยินยอมล้าสมัย ยืนยันใหม่ด้วยเวอร์ชันปัจจุบัน 400 invalid_voice_name ชื่อว่างเปล่า ยาวเกิน 60 ตัวอักษร หรือไม่ได้รับอนุญาต 400 too_many_files ไฟล์เสียงเกิน 5 ไฟล์ 401 invalid_api_key ไม่มี API key หรือ API key ไม่ถูกต้อง 402 insufficient_balance ยอดคงเหลือไม่พอ (ค่าสร้างหรือยอดขั้นต่ำ) 403 email_unverified โปรดยืนยันอีเมลของคุณก่อน 403 voice_cloning_not_enabled บัญชีของคุณยังไม่เปิดใช้เสียงที่กำหนดเอง โปรดติดต่อฝ่ายสนับสนุนลูกค้าเพื่อขอใช้ 403 voice_cloning_disabled ขณะนี้บริการนี้ยังไม่เปิดใช้เสียงที่กำหนดเอง 404 voice_not_found ไม่มีเสียงนี้ (หรือไม่ใช่ของคุณ) 404 not_found ไม่พบ รวมถึงทุกคำขอ /v1/voices ขณะที่ฟีเจอร์ยังไม่เปิดให้บัญชีของคุณ 405 method_not_allowed เมธอดนั้นใช้กับพาธนี้ไม่ได้ 409 duplicate_request Idempotency-Key เดียวกันยังประมวลผลอยู่ รอสักครู่แล้วลองใหม่ 413 file_too_large ไฟล์ใดไฟล์หนึ่งเกิน 10 MB หรือทุกไฟล์รวมกันเกิน 25 MB 415 unsupported_file_type ไม่รองรับชนิดเสียงนี้ ใช้ mp3, wav, m4a, ogg, flac, webm 422 voice_rejected การตรวจสอบของผู้ให้บริการเสียงไม่ยอมรับตัวอย่างนี้ (เช่น เสียงที่มีชื่อเสียงหรือเสียงในระบบ หรือเสียงสังเคราะห์ด้วย AI ที่เป็นที่รู้จัก) เสียงจะไม่ถูกเก็บไว้และคุณไม่ถูกเรียกเก็บเงิน ใช้การบันทึกเสียงของคุณเองที่ชัดเจน หรือเสียงที่คุณมีสิทธิ์ใช้ 429 voice_create_rate_limited ถึงขีดจำกัดการสร้างรายวันแล้ว ลองใหม่พรุ่งนี้ (UTC) 429 voice_limit_reached คุณมีเสียงที่กำหนดเองถึงจำนวนสูงสุดแล้ว 502 upstream_failed สร้างเสียงไม่สำเร็จ คุณไม่ถูกเรียกเก็บเงิน ลองใหม่ด้วย Idempotency-Key ใหม่ 503 voice_capacity_full ช่องเสียงที่กำหนดเองเต็มชั่วคราว คุณไม่ถูกเรียกเก็บเงิน ลองใหม่ภายหลัง 504 upstream_timeout บริการเสียงตอบไม่ทันเวลา คุณไม่ถูกเรียกเก็บเงิน ลองใหม่ด้วย Idempotency-Key เดิม
API ข้อมูล เร็ว ๆ นี้ — ข้อมูลโซเชียลและคอมเมิร์ซสาธารณะผ่านสาม endpoint ของ BazaarLink บริการนี้ปิดไว้เป็นค่าเริ่มต้น และคำขอจะคืนค่า service_paused จนกว่าจะเปิดใช้งาน
ส่งคำขอข้อมูลโซเชียล POST /v1/data/social
พารามิเตอร์คำขอ รหัส ประเภท จำเป็น ความหมาย platformstringใช่ รหัสแพลตฟอร์มจากแคตตาล็อก เช่น twitter หรือ instagram actionstringใช่ action ที่แพลตฟอร์มนั้นรองรับ ดูคู่ที่ใช้งานได้ในแคตตาล็อก paramsobjectไม่ใช่ ข้อมูลนำเข้าสำหรับ action นั้น ๆ ใช้ required_params และ optional_params ในแคตตาล็อก modesync | asyncไม่ใช่ ไม่บังคับ async จะคืนงานให้โพล ส่วน action ที่รองรับเฉพาะแบบอะซิงโครนัสจะคืนงานแม้ไม่ระบุค่า
รูปแบบการตอบกลับ HTTP 200 · data.social · id · object · platform · action · count · results · usage.cost
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"id" : "req_example" ,
"object" : "data.social" ,
"platform" : "twitter" ,
"action" : "search" ,
"count" : 1 ,
"results" : [
{
"id" : "post_example" ,
"url" : "https://x.com/someone/status/post_example" ,
"text" : "Example post" ,
"like_count" : 120 ,
"reply_count" : 8 ,
"retweet_count" : 14 ,
"view_count" : 5400 ,
"posted_at" : "2026-10-07T00:48:38+00:00" ,
"author_username" : "someone" ,
"author_name" : "Someone" ,
"platform" : "twitter"
}
] ,
"usage" : {
"cost" : 0.0048
}
}
⌄ ดูทั้งหมด 25 บรรทัดงานแบบอะซิงโครนัส action ที่รองรับเฉพาะแบบอะซิงโครนัสหรือ mode async จะคืน HTTP 202 พร้อม job id ที่อ่านความหมายไม่ได้ ให้โพล GET /v1/data/jobs/{id}: HTTP 202 หมายถึงกำลังรอ และ HTTP 200 จะคืนการตอบกลับ data.social ที่เสร็จแล้ว งานจะหมดอายุหลัง 15 นาที (HTTP 410 job_expired) งานที่ไม่รู้จักหรืองานของบัญชีอื่นจะคืน HTTP 404 not_found งานที่เสร็จแล้วจะคิดค่าบริการครั้งเดียวเมื่อดึงข้อมูลสำเร็จครั้งแรก
{
"platform" : "instagram" ,
"action" : "discover" ,
"params" : {
"keyword" : "coffee"
} ,
"mode" : "async"
}
⌄ ดูทั้งหมด 8 บรรทัดHTTP 202
{
"id" : "job_example" ,
"object" : "data.job" ,
"status" : "pending" ,
"platform" : "instagram" ,
"action" : "discover"
} โพลงานแบบอะซิงโครนัส GET /v1/data/jobs/{id}
HTTP 202 pending → HTTP 200 data.social · HTTP 410 job_expired · HTTP 404 not_found
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"id" : "job_example" ,
"object" : "data.social" ,
"platform" : "instagram" ,
"action" : "discover" ,
"count" : 1 ,
"results" : [
{
"id" : "post_example" ,
"url" : "https://www.instagram.com/p/example/" ,
"text" : "Example result" ,
"platform" : "instagram"
}
] ,
"usage" : {
"cost" : 0.0096
}
}
⌄ ดูทั้งหมด 18 บรรทัดแสดง action และราคา GET /v1/data/catalog
object · product · platforms · actions · required_params · optional_params · max_limit · async · price_usd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
"object" : "data.catalog" ,
"product" : "BazaarLink Data API" ,
"platforms" : [
{
"platform" : "twitter" ,
"actions" : [
{
"action" : "search" ,
"label" : "Keyword search" ,
"required_params" : [
"keyword"
] ,
"optional_params" : [
"sort"
] ,
"max_limit" : 200 ,
"async" : false ,
"price_usd" : 0.0048
}
]
} ,
{
"platform" : "instagram" ,
"actions" : [
{
"action" : "discover" ,
"label" : "Discover" ,
"required_params" : [
"keyword"
] ,
"optional_params" : [ ] ,
"max_limit" : null ,
"async" : true ,
"price_usd" : 0.0096
}
]
}
]
}
⌄ ดูทั้งหมด 40 บรรทัดการเรียกเก็บเงิน คิดราคาเป็นระดับตามแพลตฟอร์มและ action GET /v1/data/catalog แสดงราคาสำหรับลูกค้าของแต่ละ action ที่เปิดใช้ คำขอที่สำเร็จคิดค่าบริการครั้งเดียว ส่วนคำขอที่ล้มเหลวและไม่พบผลลัพธ์ไม่มีค่าใช้จ่าย Data API และการค้นหาเว็บใช้โควต้าฟรีรายวันร่วมกัน
รหัสข้อผิดพลาด {"error":{"code":"<code>","message":"<fixed message>"}}
รหัส HTTP ความหมาย unauthorized401 ไม่มี API key หรือ API key ไม่ถูกต้อง forbidden403 ไม่อนุญาตคำขอ invalid_request400 เนื้อหาคำขอไม่ถูกต้อง invalid_params400 พารามิเตอร์ของ action ถูกปฏิเสธ unsupported_capability400 แพลตฟอร์มหรือ action ไม่พร้อมใช้งาน insufficient_credits402 เครดิตไม่เพียงพอ budget_cap_reached402 or policy status ถึงขีดจำกัดการใช้จ่ายของบัญชีแล้ว body_too_large413 เนื้อหาคำขอเกินขนาดที่กำหนด free_quota_exhausted432 ใช้โควต้าฟรีรายวันหมดแล้ว rate_limited429 ถึงขีดจำกัดอัตราแล้ว ให้ปฏิบัติตาม Retry-After data_unavailable503 บริการข้อมูลไม่พร้อมใช้งานชั่วคราว timeout504 คำขอหมดเวลา bad_upstream_response502 บริการข้อมูลคืนการตอบกลับที่ไม่ถูกต้อง job_expired410 งานหมดอายุหลัง 15 นาที not_found404 ไม่พบงานหรืองานเป็นของบัญชีอื่น job_failed503 งานแบบอะซิงโครนัสล้มเหลว service_paused503 ยังไม่ได้เปิดใช้บริการหรือบริการหยุดชั่วคราว
ตัวอย่าง curl curl https://api.bazaarlink.ai/v1/data/social \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{"platform":"twitter","action":"search","params":{"keyword":"BazaarLink","limit":5}}' Python (requests) import os
import requests
response = requests.post(
"https://api.bazaarlink.ai/v1/data/social" ,
headers={"Authorization" : f"Bearer {os.environ['BAZAARLINK_API_KEY' ]} " },
json={"platform" : "twitter" , "action" : "search" , "params" : {"keyword" : "BazaarLink" , "limit" : 5 }},
timeout=30 ,
)
response.raise_for_status()
print (response.json())
⌄ ดูทั้งหมด 11 บรรทัดJavaScript (fetch) const response = await fetch ("https://api.bazaarlink.ai/v1/data/social" , {
method : "POST" ,
headers : {
Authorization : `Bearer ${process.env.BAZAARLINK_API_KEY} ` ,
"Content-Type" : "application/json" ,
},
body : JSON .stringify ({ platform : "twitter" , action : "search" , params : { keyword : "BazaarLink" , limit : 5 } }),
});
if (!response.ok ) throw new Error (`HTTP ${response.status} ` );
console .log (await response.json ());
⌄ ดูทั้งหมด 10 บรรทัดSubmit a decisions request Evaluate a state against named questions with a decisions-output model. This alpha endpoint returns non-streaming JSON. Find available model ids with GET /v1/models?output_modalities=decisions; use this endpoint for Clef instead of chat/completions. Input tokens are billed at the selected model's customer price. Sufficient credits are required. Set BAZAARLINK_API_KEY to your API key; the sample builds its complete Authorization header in BAZAARLINK_AUTH_HEADER.
View the decisions API reference
export BAZAARLINK_AUTH_HEADER="Authorization: $(printf '%s %s' 'Bearer' "$BAZAARLINK_API_KEY " ) "
curl https://api.bazaarlink.ai/v1/alpha/decisions \
-H "$BAZAARLINK_AUTH_HEADER " \
-H "Content-Type: application/json" \
-d '{
"model": "cloudflare/clef-flash",
"state": "The support agent issued a full refund.",
"questions": {
"refunded": {
"type": "noul",
"instructions": "Was a refund issued?"
}
}
}'
⌄ ดูทั้งหมด 15 บรรทัดResponses API Endpoint ที่รองรับ OpenAI Responses API สำหรับการสนทนาหลายรอบแบบ stateless, tool calling และอินพุต multimodal เหมาะสำหรับ agent และเฟรมเวิร์กที่ใช้ OpenAI Python SDK ≥ 1.x กับ client.responses.create()
POST /v1/responses
Note
รับการยืนยันตัวตนและการกำหนดเส้นทางโมเดลเดียวกับ Chat Completions
เนื้อความคำขอ modelจำเป็น
string
ใช้ id หรือ alias ที่แสดงใน GET /v1/models เช่น "claude-sonnet-4.6" หรือ "anthropic/claude-sonnet-4.6"
inputจำเป็น
string | Item[]
อินพุตผู้ใช้ — สตริงธรรมดา (ข้อความเดียว) หรืออาร์เรย์ของรายการอินพุตสำหรับการสนทนาหลายรอบ/multimodal
instructions
string
คำสั่งระดับระบบ เทียบเท่ากับข้อความระบบ ต้องส่งใหม่ทุกคำขอ
stream
boolean
ถ้า true จะส่งคืน Responses API SSE stream events ประเภทเหตุการณ์: response.created, response.output_text.delta, response.completed
max_output_tokens
integer
จำนวนโทเค็นเอาต์พุตสูงสุดที่จะสร้าง (รวมโทเค็นการใช้เหตุผลสำหรับโมเดล o-series)
temperature
number
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
top_p
number
มวลความน่าจะเป็นการสุ่มตัวอย่าง Nucleus ค่าเริ่มต้น: 1
tools
Tool[]
คำจำกัดความเครื่องมือ (ฟังก์ชัน) — รูปแบบ JSON Schema เดียวกับ Chat Completions (รับทั้งรูปแบบแบนของ Responses และรูปแบบซ้อน) เครื่องมือโฮสต์ในตัวของ OpenAI เอง (web_search_preview, file_search, computer_use_preview) ไม่รองรับ; การค้นหาเว็บใช้ได้ผ่าน plugins: [{id:"web"}] — รองรับเฉพาะบางเส้นทางโมเดล
tool_choice
string | object
ควบคุมการใช้เครื่องมือ: "auto", "none" หรือเครื่องมือเฉพาะ
parallel_tool_calls
boolean
เปิดใช้งานการเรียกฟังก์ชันแบบขนานเมื่อมีเครื่องมือ ค่าเริ่มต้น: true ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
response_format
object
บังคับเอาต์พุต JSON ที่มีโครงสร้าง ดูส่วน Structured Output
previous_response_id
string
เอนด์พอยต์นี้ไม่มีสถานะ — การส่งค่าที่ไม่ใช่ null จะคืนค่า 400 (invalid_prompt) ทันที ไม่เคยถูกยอมรับแล้วละเว้น ให้ใช้โหมด stateless แทน: ส่งประวัติการสนทนาเต็มในอาร์เรย์ input
Request Schema (TypeScript) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type ResponsesRequest = {
model : string ;
input : string | InputItem [];
instructions ?: string ;
stream ?: boolean ;
max_output_tokens ?: number ;
temperature ?: number ;
top_p ?: number ;
tools ?: Tool [];
tool_choice ?: "auto" | "none" | "required" | object ;
parallel_tool_calls ?: boolean ;
previous_response_id ?: string ;
};
type InputItem =
| { type ?: "message" ; role : "user" | "assistant" | "system" | "developer" ; content : string | ContentBlock [] }
| { type : "function_call_output" ; call_id : string ; output : string }
| { type : "function_call" ; call_id : string ; name : string ; arguments : string };
type ContentBlock =
| { type : "input_text" ; text : string }
| { type : "input_image" ; image_url : string ; detail ?: "auto" | "low" | "high" };
⌄ ดูทั้งหมด 24 บรรทัดตัวอย่างคำขอ cURL Python Multi-turn Streaming
curl https://api.bazaarlink.ai/v1/responses \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-mini",
"instructions": "You are a helpful assistant.",
"input": "What is the capital of Taiwan?"
}'
⌄ ดูทั้งหมด 8 บรรทัดรูปแบบการตอบกลับ BazaarLink ส่งคืน response แบบมาตรฐานและลบฟิลด์เฉพาะของ upstream ออก request ID แบบ opaque ของ BazaarLink ใน response ตรงกับ x-request-id ใช้ร่วมกับ GET /v1/generation response แบบ non-streaming จะส่ง ID เดียวกันใน x-generation-id ด้วย usage.cost คือจำนวนเงิน USD ที่เรียกเก็บจากลูกค้า สถิติอาจพร้อมใช้งานหลังเสร็จสิ้นไม่กี่วินาที หากได้ 404 ให้ลองซ้ำช่วงสั้นๆ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
type ResponsesResponse = {
id : string ;
object : "response" ;
created_at : number ;
completed_at : number ;
status : "completed" | "failed" | "incomplete" ;
model : string ;
output : OutputItem [];
usage : {
input_tokens : number ;
output_tokens : number ;
total_tokens : number ;
cost ?: number ;
} | null ;
error : null | { code : string ; message : string };
};
type OutputItem =
| {
type : "message" ;
id : string ;
role : "assistant" ;
status : "completed" ;
content : Array <{ type : "output_text" ; text : string ; annotations : [] }>;
}
| { type : "function_call" ; id : string ; call_id : string ; name : string ; arguments : string ; status : "completed" };
⌄ ดูทั้งหมด 27 บรรทัดย้ายจาก Chat Completions แทนที่ messages ด้วย input (สตริงหรืออาร์เรย์) ใช้ instructions แทนข้อความบทบาทระบบ และอ่าน output[0].content[0].text แทน choices[0].message.content
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
response = client.chat.completions.create(
model="openai/gpt-5.4-mini" ,
messages=[
{"role" : "system" , "content" : "You are helpful." },
{"role" : "user" , "content" : "Hello" },
]
)
text = response.choices[0 ].message.content
response = client.responses.create(
model="openai/gpt-5.4-mini" ,
instructions="You are helpful." ,
input ="Hello"
)
text = response.output[0 ].content[0 ].text
⌄ ดูทั้งหมด 17 บรรทัดข้อจำกัด previous_response_id หรือ store: true จะถูกปฏิเสธด้วย 400 (รหัสข้อผิดพลาด invalid_prompt) — ไม่ใช่ถูกยอมรับแล้วละเว้น ให้ใช้โหมด stateless เสมอ: ส่งประวัติการสนทนาเต็มในอาร์เรย์ input เครื่องมือโฮสต์ในตัวของ OpenAI เอง (web_search_preview, file_search, computer_use_preview) ไม่รองรับ การค้นหาเว็บใช้ได้ผ่าน plugins: [{id:"web"}] — รองรับเฉพาะบางเส้นทางโมเดล background: true ได้รับการยอมรับแต่ถูกละเว้น — ทุกคำขอทำงานแบบซิงโครนัสจนเสร็จสมบูรณ์เสมอ Messages (Anthropic) Messages API ที่เข้ากันได้กับ Anthropic สำหรับ Claude SDK ชี้ SDK มาที่ BazaarLink และใช้ BazaarLink API key; ฟิลด์ response และ metadata การเรียกเก็บเงินเป็นไปตามสัญญา BazaarLink ที่ระบุด้านล่าง
POST /v1/messages
Note
Accepts Bearer token หรือส่วนหัว x-api-key (ความเข้ากันได้ Anthropic SDK) ขนาดตัวเครื่องสูงสุด: 10 MB
เนื้อความคำขอ modelจำเป็น
string
ใช้ id หรือ alias ที่แสดงใน GET /v1/models เช่น "claude-sonnet-4.6" หรือ "anthropic/claude-sonnet-4.6"
max_tokensจำเป็น
integer
จำนวนโทเค็นสูงสุดที่จะสร้าง (จำนวนเต็มบวก)
messagesจำเป็น
Message[]
Array ของข้อความการสนทนา (ไม่ว่างเปล่า)
system
string
พร้อมท์ระบบเสริม
stream
boolean
ถ้า true จะส่งคืน Server-Sent Events stream ค่าเริ่มต้น: false
temperature
number
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
top_p
number
มวลความน่าจะเป็นการสุ่มตัวอย่าง Nucleus ค่าเริ่มต้น: 1
top_k
integer
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
stop_sequences
string[]
สตริงลำดับการหยุดแบบกำหนดเอง
tools
Tool[]
รายการเครื่องมือ (ฟังก์ชัน) ที่โมเดลอาจเรียกใช้
tool_choice
string | object
ควบคุมการใช้เครื่องมือ: "auto", "none" หรือเครื่องมือเฉพาะ
ตัวอย่างคำขอ Python TypeScript cURL
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.bazaarlink.ai/v1" ,
api_key="sk-bl-YOUR_KEY"
)
response = client.messages.create(
model="anthropic/claude-opus-4.6" ,
max_tokens=1024 ,
messages=[{"role" : "user" , "content" : "Hello" }]
)
print (response.content[0 ].text)
⌄ ดูทั้งหมด 13 บรรทัดการตอบสนอง BazaarLink ส่งคืน response แบบมาตรฐานและลบฟิลด์เฉพาะของ upstream ออก request ID แบบ opaque ของ BazaarLink ใน response ตรงกับ x-request-id ใช้ร่วมกับ GET /v1/generation response แบบ non-streaming จะส่ง ID เดียวกันใน x-generation-id ด้วย usage.cost และ usage.bz_cost เป็นจำนวนเงิน USD เดียวกันที่เรียกเก็บจากลูกค้า สถิติอาจพร้อมใช้งานหลังเสร็จสิ้นไม่กี่วินาที หากได้ 404 ให้ลองซ้ำช่วงสั้นๆ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"id" : "85e6f35c71a31f19-SJC" ,
"type" : "message" ,
"role" : "assistant" ,
"model" : "anthropic/claude-opus-4.6" ,
"content" : [
{ "type" : "text" , "text" : "Hello! How can I help you today?" }
] ,
"stop_reason" : "end_turn" ,
"usage" : {
"input_tokens" : 10 ,
"output_tokens" : 12 ,
"cache_read_input_tokens" : 0 ,
"cache_creation_input_tokens" : 0 ,
"cost" : 0.00042 ,
"bz_cost" : 0.00042
}
}
⌄ ดูทั้งหมด 18 บรรทัดรูปแบบ error envelope แตกต่างกันตามความล้มเหลว ใช้ HTTP status และ error.type เมื่อมี error.code อาจเป็น string, numeric HTTP status หรืออาจไม่มี ดูแนวทางการจัดการในหัวข้อ Errors
โมเดล แสดงรายการโมเดลทั้งหมดที่พร้อมใช้งานพร้อมข้อมูลราคาและความสามารถ ไม่ต้องยืนยันตัวตนสำหรับ endpoint นี้
GET /v1/models
cURL Python fetch
curl https://api.bazaarlink.ai/v1/models
curl "https://api.bazaarlink.ai/v1/models?output_modalities=all" การตอบสนอง {
"data" : [
{
"id" : "openai/gpt-4o" ,
"name" : "GPT 4.1" ,
"context_length" : 1047576 ,
"modality" : "text+image+file->text" ,
"pricing" : {
"prompt" : "2.00" ,
"completion" : "8.00"
}
}
]
}
⌄ ดูทั้งหมด 14 บรรทัด1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
type ModelsResponse = {
data : Model [];
};
type Model = {
id : string ;
name : string ;
context_length : number | null ;
modality : string | null ;
architecture ?: {
input_modalities ?: string [];
output_modalities ?: Array <
"text" | "image" | "embeddings" | "audio" |
"video" | "rerank" | "speech" | "transcription"
>;
};
pricing : {
prompt : string ;
completion : string ;
input_cache_read ?: string ;
input_cache_write ?: string ;
image_output ?: string ;
};
description ?: string | null ;
top_provider ?: {
max_completion_tokens ?: number ;
};
supported_parameters ?: string [];
pricing_tiers ?: {
above_prompt_tokens : number ;
prompt : string ;
completion : string ;
input_cache_read ?: string ;
input_cache_write ?: string ;
}[];
};
⌄ ดูทั้งหมด 37 บรรทัดราคาแบบขั้นบันไดตามความยาวอินพุต บางโมเดลจะเปลี่ยนไปใช้ตารางราคาอื่นเมื่อพรอมต์เกินเกณฑ์ token — ตารางทั้งหมดเปลี่ยน ไม่ใช่แค่ส่วนที่เกินเกณฑ์ เกณฑ์เป็นอสมการแบบเข้ม: พรอมต์ที่มี token เท่ากับ N พอดียังคงคิดราคาที่ขั้นต่ำกว่า N; ขั้นที่สูงกว่าจะใช้ก็ต่อเมื่อ token อินพุตมากกว่า N เท่านั้น
pricing_tiers เป็นฟิลด์ระดับเดียวกับ pricing จะปรากฏเฉพาะเมื่อโมเดลมีขั้นราคาที่ override เกินกว่าราคาฐาน รายการเรียงตาม above_prompt_tokens จากน้อยไปมาก; prompt/completion คือราคา USD ต่อ token (หน่วยเดียวกับ pricing.prompt/pricing.completion) pricing.prompt และ pricing.completion จะเป็นขั้นฐาน (ต่ำสุด) เสมอ
โมเดลส่วนใหญ่ไม่มีขั้นราคา — สำหรับโมเดลเหล่านั้น จะไม่มีคีย์ pricing_tiers ในการตอบกลับเลย
{
"id" : "openai/gpt-4o" ,
"name" : "GPT 4.1" ,
"pricing" : {
"prompt" : "2.00" ,
"completion" : "8.00"
} ,
"pricing_tiers" : [
{
"above_prompt_tokens" : 128000 ,
"prompt" : "4.00" ,
"completion" : "16.00"
}
]
}
⌄ ดูทั้งหมด 15 บรรทัดโมเดลที่พร้อมใช้งาน (171) เหล่านี้คือโมเดลที่พร้อมใช้งานบน BazaarLink โหลดแบบไดนามิกจากฐานข้อมูลของเรา:
Qwen
qwen/qwen3.8-max1000K ctx · $1.65/$4.95 text+image+video->text
qwen/qwen3.7-plus1000K ctx · $0.32/$1.28 text+image->text
qwen/qwen3.7-max1000K ctx · $1.65/$4.95 text->text
qwen/qwen3.7-flash1000K ctx · $0.03/$0.13 text+image+video->text
qwen/qwen3.5-35b-a3b262K ctx · $0.31/$1.25 text+image+video->text
qwen/qwen3.5-27b262K ctx · $0.26/$2.60 text+image+video->text
qwen/qwen3-next-80b-a3b-instruct262K ctx · $0.14/$0.57 text->text
qwen/qwen3.5-397b-a17b262K ctx · $0.55/$3.50 text+image+video->text
qwen/qwen3.6-plus1000K ctx · $0.33/$1.95 text+image+video->text
qwen/qwen3-coder-flash1000K ctx · $0.20/$0.97 text->text
qwen/qwen3.5-122b-a10b262K ctx · $0.40/$3.20 text+image+video->text
qwen/qwen3-vl-235b-a22b-instruct262K ctx · $0.20/$0.88 text+image->text
qwen/qwen3.8-27b1000K ctx · $0.50/$3.00 text+image+video->text
qwen/qwen3.8-2.4t-a95b1049K ctx · $2.00/$6.00 text->text
qwen/qwen3-embedding-8b33K ctx · $0.01/$0.00 text->embeddings
qwen/qwen3-embedding-0.6b33K ctx · $0.01/$0.00 text->embeddings
qwen/qwen3-embedding-4b33K ctx · $0.02/$0.00 text->embeddings
qwen/qwen3.5-flash-02-231000K ctx · $0.07/$0.26 text+image+video->text
qwen/qwen3-coder-30b-a3b-instruct262K ctx · $0.07/$0.28 text->text
qwen/qwen3.6-35b-a3b262K ctx · $0.15/$1.00 text+image+video->text
qwen/qwen3-coder-next262K ctx · $0.12/$0.80 text->text
qwen/qwen3-vl-30b-a3b-instruct262K ctx · $0.15/$0.60 text+image->text
qwen/qwen3.5-plus-02-151000K ctx · $0.26/$1.56 text+image+video->text
qwen/qwen3.6-27b262K ctx · $0.29/$2.40 text+image+video->text
qwen/qwen3.5-plus-202604201000K ctx · $0.30/$1.80 text+image+video->text
qwen/qwen3-coder262K ctx · $0.30/$1.00 text->text
qwen/qwen-2.5-72b-instruct33K ctx · $0.36/$0.40 text->text
qwen/qwen-image-3 · $0.00/$0.00 text+image->image
qwen/qwen-image-3-pro · $0.00/$0.00 text+image->image
Google
google/gemini-4-argon1049K ctx · $2.00/$10.00 text+image+file+audio+video->text
google/gemini-3.1-flash-lite-preview1049K ctx · $0.25/$1.50 text+image+file+audio+video->text
google/gemini-3.1-pro-preview1049K ctx · $2.00/$12.00 text+image+file+audio+video->text
google/gemma-3-4b-it131K ctx · $0.05/$0.10 text+image->text
google/gemini-3.1-flash-lite1049K ctx · $0.25/$1.50 text+image+file+audio+video->text
google/gemini-3.5-flash-lite1049K ctx · $0.30/$2.50 text+image+file+audio+video->text
google/gemini-3-flash-preview1049K ctx · $0.50/$3.00 text+image+file+audio+video->text
google/gemini-3.7-flash1049K ctx · $0.75/$3.75 text+image+file+audio+video->text
google/gemini-3.8-flash1049K ctx · $0.75/$3.75 text+image+file+audio+video->text
google/gemini-3.6-flash1049K ctx · $0.75/$3.75 text+image+file+audio+video->text
google/gemini-3.5-flash1049K ctx · $1.50/$9.00 text+image+file+audio+video->text
google/text-embedding-0052K ctx · $0.03/$0.00 text->embeddings
google/text-multilingual-embedding-0022K ctx · $0.03/$0.00 text->embeddings
google/gemini-embedding-00120K ctx · $0.15/$0.00 text->embeddings
google/gemma-4-26b-a4b-it262K ctx · $0.09/$0.34 text+image+video->text
google/gemma-4-31b-it262K ctx · $0.09/$0.34 text+image+video->text
google/gemini-2.5-flash-image33K ctx · $0.30/$2.50 text+image->text+image
google/gemini-3.1-flash-image-preview66K ctx · $0.50/$3.00 text+image->text+image
google/gemini-3.1-flash-image131K ctx · $0.50/$3.00 text+image->text+image
google/gemini-3-pro-image131K ctx · $2.00/$12.00 text+image->text+image
google/veo-3.1 · $0.00/$0.00 text+image->video
google/gemini-embedding-2-preview8K ctx · $0.20/$0.00 text+image+file+audio+video->embeddings
google/gemini-nano-banana-2.166K ctx · $1.50/$7.50 text+image->text+image
OpenAI
openai/gpt-5.3-codex400K ctx · $1.75/$14.00 text->text
openai/gpt-6-luna1050K ctx · $0.10/$0.50 text+image+file->text
openai/gpt-5.6-luna1050K ctx · $0.20/$1.20 text+image+file->text
openai/gpt-5.4-mini400K ctx · $0.75/$4.50 text+image+file->text
openai/gpt-6.1-sol1050K ctx · $2.00/$10.00 text+image+file->text
openai/gpt-6-sol1050K ctx · $2.00/$10.00 text+image+file->text
openai/gpt-5.41050K ctx · $2.50/$15.00 text+image+file->text
openai/gpt-5.51050K ctx · $5.00/$30.00 text+image+file->text
openai/gpt-6-astra1050K ctx · $10.00/$50.00 text+image+file->text
openai/gpt-5.6-terra1050K ctx · $2.00/$12.00 text+image+file->text
openai/text-embedding-3-small8K ctx · $0.02/$0.00 text->embeddings
openai/gpt-oss-safeguard-20b128K ctx · $0.07/$0.30 text->text
openai/gpt-oss-120b131K ctx · $0.15/$0.60 text->text
openai/text-embedding-ada-0028K ctx · $0.10/$0.00 text->embeddings
openai/text-embedding-3-large · $0.13/$0.00 text->embeddings
openai/gpt-5.6-sol1050K ctx · $4.00/$20.00 text+image+file->text
openai/gpt-oss-20b131K ctx · $0.03/$0.13 text->text
openai/gpt-4o128K ctx · $2.50/$10.00 text+image+file->text
openai/gpt-image-1-mini400K ctx · $2.50/$2.50 text+image->image
openai/gpt-5.4-image-2272K ctx · $8.00/$15.00 text+image+file->text+image
openai/gpt-image-2.5-flare400K ctx · $8.00/$8.00 text+image->image
openai/gpt-image-2.5-sunburst400K ctx · $8.00/$8.00 text+image->image
openai/gpt-image-1400K ctx · $10.00/$10.00 text+image->image
Anthropic
anthropic/claude-sonnet-4.61000K ctx · $3.00/$15.00 text+image+file->text
anthropic/claude-opus-4.61000K ctx · $5.00/$25.00 text+image+file->text
anthropic/claude-haiku-5.51000K ctx · $0.10/$0.50 text+image+file->text
anthropic/claude-haiku-4.5200K ctx · $1.00/$5.00 text+image+file->text
anthropic/claude-sonnet-51000K ctx · $2.00/$10.00 text+image+file->text
anthropic/claude-sonnet-5.51000K ctx · $2.00/$10.00 text+image+file->text
anthropic/claude-sonnet-4.51000K ctx · $3.00/$15.00 text+image+file->text
anthropic/claude-opus-5.51000K ctx · $4.00/$20.00 text+image+file->text
anthropic/claude-opus-4.81000K ctx · $5.00/$25.00 text+image+file->text
anthropic/claude-opus-4.71000K ctx · $5.00/$25.00 text+image+file->text
anthropic/claude-opus-51000K ctx · $5.00/$25.00 text+image+file->text
anthropic/claude-opus-4.5200K ctx · $5.00/$25.00 text+image+file->text
anthropic/claude-fable-5.11000K ctx · $10.00/$50.00 text+image+file->text
anthropic/claude-fable-51000K ctx · $10.00/$50.00 text+image+file->text
anthropic/claude-opus-4.1200K ctx · $15.00/$75.00 text+image+file->text
DeepSeek
deepseek/deepseek-v4.1-flash-10171049K ctx · $0.21/$0.85 text+image->text
deepseek/deepseek-v4-flash1049K ctx · $0.14/$0.28 text->text
deepseek/deepseek-v4-pro1049K ctx · $1.65/$3.30 text->text
deepseek/deepseek-v4.1-flash1049K ctx · $0.21/$0.85 text+image->text
deepseek/deepseek-chat-v3.1164K ctx · $0.21/$0.79 text->text
deepseek/deepseek-chat164K ctx · $0.26/$0.38 text->text
deepseek/deepseek-r164K ctx · $0.50/$2.15 text->text
deepseek/deepseek-v4-pro-08131049K ctx · $0.89/$2.67 text->text
deepseek/deepseek-v4-flash-07311000K ctx · $0.44/$1.32 text->text
deepseek/deepseek-r1-0528164K ctx · $0.50/$2.15 text->text
deepseek/deepseek-v4-flash-0731free1049K ctx · $0.20/$0.40 text->text
elevenlabs
elevenlabs/eleven-v4-turbo · $0.00/$0.00 text->speech
elevenlabs/eleven-multilingual-v2 · $0.00/$0.00 text->speech
elevenlabs/eleven-v4 · $0.00/$0.00 text->speech
elevenlabs/eleven-turbo-v2.5 · $0.00/$0.00 text->speech
elevenlabs/eleven-flash-v2 · $0.00/$0.00 text->speech
elevenlabs/eleven-v3-conversational · $0.00/$0.00 text->speech
elevenlabs/eleven-flash-v2.5 · $0.00/$0.00 text->speech
elevenlabs/eleven-v3 · $0.00/$0.00 text->speech
elevenlabs/eleven-turbo-v2 · $0.00/$0.00 text->speech
elevenlabs/scribe-v2 · $0.00/$0.00 audio->transcription
elevenlabs/scribe-v2-medical · $0.00/$0.00 audio->transcription
Zhipu AI
z-ai/glm-5v-turbo203K ctx · $1.20/$4.00 text+image+video->text
z-ai/glm-5.3-flash1049K ctx · $0.15/$0.50 text+image+video->text
z-ai/glm-4.6205K ctx · $0.60/$2.20 text->text
z-ai/glm-5.3-flashx1049K ctx · $0.37/$1.25 text+image+video->text
z-ai/glm-5.31049K ctx · $1.13/$4.40 text->text
z-ai/glm-4.7-flash200K ctx · $0.06/$0.40 text->text
z-ai/glm-4.5-air131K ctx · $0.13/$0.85 text->text
z-ai/glm-4.6v131K ctx · $0.30/$0.90 text+image+video->text
z-ai/glm-4.5v66K ctx · $0.60/$1.80 text+image->text
z-ai/glm-4.5131K ctx · $0.60/$2.20 text->text
voyage
voyage/voyage-4-lite32K ctx · $0.02/$0.00 text->embeddings
voyage/voyage-3.5-lite32K ctx · $0.02/$0.00 text->embeddings
voyage/voyage-3.532K ctx · $0.06/$0.00 text->embeddings
voyage/voyage-432K ctx · $0.06/$0.00 text->embeddings
voyage/voyage-4-large32K ctx · $0.12/$0.00 text->embeddings
voyage/voyage-law-216K ctx · $0.12/$0.00 text->embeddings
voyage/voyage-finance-232K ctx · $0.12/$0.00 text->embeddings
voyage/voyage-code-216K ctx · $0.12/$0.00 text->embeddings
voyage/voyage-3-large32K ctx · $0.18/$0.00 text->embeddings
voyage/voyage-code-332K ctx · $0.18/$0.00 text->embeddings
xAI
x-ai/grok-build-0.1256K ctx · $1.00/$2.00 text+image+file->text
x-ai/grok-4.31000K ctx · $1.25/$2.50 text+image+file->text
x-ai/grok-4.6500K ctx · $2.00/$6.00 text+image+file->text
x-ai/grok-4.5500K ctx · $2.00/$6.00 text+image+file->text
x-ai/grok-4.7500K ctx · $2.00/$6.00 text+image->text
x-ai/grok-4.202000K ctx · $1.25/$2.50 text+image+file->text
x-ai/grok-imagine-video-1.5-lite · $0.00/$0.00 text+image->video
x-ai/grok-imagine-image-2.0 · $0.00/$0.00 text+image->image
bytedance-seed
bytedance-seed/seed-1.6-flash262K ctx · $0.07/$0.30 text+image+video->text
bytedance-seed/seed-2.0-mini262K ctx · $0.10/$0.40 text+image+video->text
bytedance-seed/seed-2.0-lite262K ctx · $0.25/$2.00 text+image+video->text
bytedance-seed/seed-1.6262K ctx · $0.25/$2.00 text+image+video->text
ByteDance
bytedance/seedance-2.5 · $0.00/$0.00 text+image+audio+video->video
bytedance/seedance-2.0 · $0.00/$0.00 text+image+audio+video->video
bytedance/seedance-1-5-pro · $0.00/$0.00 text+image->video
bytedance/seedance-2.0-fast · $0.00/$0.00 text+image+audio+video->video
Moonshot AI
moonshotai/kimi-k31049K ctx · $2.83/$14.13 text+image+video->text
moonshotai/kimi-k3.1-pro1049K ctx · $2.00/$10.00 text+image+video->text
moonshotai/kimi-k2-0905262K ctx · $0.60/$2.50 text->text
Cohere
cohere/rerank-v3.54K ctx · $0.00/$0.00 text->rerank
cohere/rerank-4-pro33K ctx · $0.00/$0.00 text->rerank
cohere/rerank-4-fast33K ctx · $0.00/$0.00 text->rerank
MiniMax
minimax/minimax-m31049K ctx · $0.30/$1.20 text+image+video->text
minimax/hailuo-3-max · $0.00/$0.00 text+image->video
xiaomi
xiaomi/mimo-v2.6-flash1049K ctx · $0.14/$0.28 text+image+video+audio->text
xiaomi/mimo-v2.6-pro1049K ctx · $0.43/$0.87 text+image+video+audio->text
reflection
reflection/beam-free1049K ctx · $0.00/$0.00 text->text
reflection/beam1049K ctx · $0.00/$0.00 text->text
Perplexity
perplexity/pplx-embed-v1-0.6b32K ctx · $0.00/$0.00 text->embeddings
perplexity/pplx-embed-v1-4b32K ctx · $0.03/$0.00 text->embeddings
Mistral
mistralai/mistral-embed-23128K ctx · $0.10/$0.00 text->embeddings
mistralai/codestral-embed-25058K ctx · $0.15/$0.00 text->embeddings
cloudflare
cloudflare/clef-flash25K ctx · $0.09/$0.00 text+image->decisions
cloudflare/clef66K ctx · $0.24/$0.00 text+image->decisions
NVIDIA
nvidia/nemotron-3.5-lightning-free1000K ctx · $0.00/$0.00 text->text
stealth
stealth/glyph-cluster256K ctx · $0.00/$0.00 text->text
Meta
meta/muse-wonder1049K ctx · $4.00/$20.00 text+image+file->text
amazon
amazon/titan-embed-text-v28K ctx · $0.02/$0.00 text->embeddings
typesafe-ai
typesafe-ai/jev32K ctx · $0.04/$0.00 text->decisions
เรียกดูโมเดลทั้งหมดบน หน้าโมเดล
การประเมินแบบมีโครงสร้าง (Jev) Jev ประเมินสถานะ JSON ตามคำถามที่ตั้งชื่อไว้ และส่งคำตอบชนิด boolean, choice หรือ score ใช้เมื่อต้องการผลประเมินที่โปรแกรมอ่านได้จากเกณฑ์ที่ชัดเจน
ใช้เพื่อประเมินและตัดสินเท่านั้น
Jev ไม่รองรับแชต ส่งคำขอ Jev ไปที่ POST /v1/evaluations หากส่งไปที่ POST /v1/chat/completions จะได้รับ HTTP 400
POST /v1/evaluations
เรียก endpoint นี้ด้วย API key ของ BazaarLink URL เต็มคือ https://api.bazaarlink.ai/v1/evaluations
คำอธิบายฟิลด์ model
string
ไม่บังคับ หากละไว้จะใช้ typesafe-ai/jev เป็นค่าเริ่มต้น โมเดล ID อื่นจะตอบ HTTP 400 พร้อมรหัส model_not_available
state
string | object | array
จำเป็น ระบุสถานะที่ต้องการประเมินเป็น JSON string, object หรือ array หาก state และ questions หลัง serialize รวมกันเกิน 32,000 tokens จะตอบ context_length_exceeded
questions
record<string, Question>
จำเป็น ต้องเป็น object ที่ไม่ว่างและมีคำถามระบุชื่อ ชื่อคำถามแต่ละข้อจะเป็น key ใน object answers ของการตอบกลับ
type
boolean | choice | score
จำเป็นสำหรับทุกคำถาม เลือก boolean, choice หรือ score
instructions
string | object | array
จำเป็นสำหรับทุกคำถาม เป็น JSON string, object หรือ array ที่อธิบายสิ่งที่ต้องตัดสิน
criteria
object | array
ขึ้นกับ type: boolean ไม่จำเป็นต้องระบุ หากระบุต้องเป็น object ที่มี key true หรือ false เท่านั้น; choice ต้องเป็น object ที่ไม่ว่าง; score ต้องเป็น array ตามลำดับที่มีอย่างน้อยสองรายการ
ชนิดคำตอบ boolean — criteria ไม่จำเป็นต้องระบุ หากระบุ จะรับเฉพาะคีย์ true และ false คำตอบมีค่า probability เป็นตัวเลขchoice — criteria ต้องเป็นออบเจ็กต์ที่ไม่ว่างซึ่งจับคู่ชื่อ option กับ JSON criteria คำตอบมี choice เป็นสตริง และ probabilities ใช้ชื่อ option เป็นคีย์score — criteria ต้องเป็นอาร์เรย์เรียงลำดับที่มีอย่างน้อยสองรายการ score เป็นตัวเลขและเป็นค่าคาดหมายของดัชนี 0..N-1 ตามลำดับในอาร์เรย์ criteria ส่วน probabilities ใช้ดัชนีเหล่านี้ในรูปสตริงเป็นคีย์ตัวอย่างคำขอ cURL Python TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
curl --fail-with-body https://api.bazaarlink.ai/v1/evaluations \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "typesafe-ai/jev",
"state": "The support agent issued a full refund and apologised for the delay.",
"questions": {
"refunded": {
"type": "boolean",
"instructions": "Was a refund issued?"
},
"tone": {
"type": "choice",
"instructions": "Tone of the agent?",
"criteria": {
"apologetic": "The agent apologises",
"neutral": "No emotional language",
"hostile": "The agent is rude"
}
},
"quality": {
"type": "score",
"instructions": "How complete was the resolution?",
"criteria": [
"poor",
"partial",
"complete"
]
}
}
}'
⌄ ดูทั้งหมด 31 บรรทัดตัวอย่างการตอบกลับเมื่อสำเร็จ ตัวอย่างการตอบกลับมี id, object, model, answers, usage, rounding และ warnings โดย answers ใช้ชื่อคำถามเป็นคีย์ usage มี input_tokens, output_tokens และ total_tokens ส่วน rounding แสดง probabilityDecimals และ scoreDecimals warnings เป็นอาร์เรย์และว่างเปล่าในตัวอย่างนี้ ภายใน answers, probabilities ของ choice ใช้ชื่อ option เป็นคีย์ ส่วน probabilities ของ score ใช้ดัชนี criteria ในรูปสตริงเป็นคีย์
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
"id" : "eval-a3d350e5-2705-4a9b-be7c-838fa4e4eb2b" ,
"object" : "evaluation" ,
"model" : "typesafe-ai/jev" ,
"answers" : {
"refunded" : {
"type" : "boolean" ,
"probability" : 0.99
} ,
"tone" : {
"type" : "choice" ,
"choice" : "apologetic" ,
"probabilities" : {
"apologetic" : 1 ,
"neutral" : 0 ,
"hostile" : 0
}
} ,
"quality" : {
"type" : "score" ,
"score" : 1.98 ,
"probabilities" : {
"0" : 0 ,
"1" : 0.02 ,
"2" : 0.98
}
}
} ,
"usage" : {
"input_tokens" : 394 ,
"output_tokens" : 74 ,
"total_tokens" : 468
} ,
"rounding" : {
"probabilityDecimals" : 2 ,
"scoreDecimals" : 2
} ,
"warnings" : [ ]
}
⌄ ดูทั้งหมด 39 บรรทัดการตอบกลับเมื่อปลายทางแชตเกิดข้อผิดพลาด เมื่อส่ง Jev ไปยังปลายทางแชต จะได้รับ HTTP 400 ฟิลด์และค่าด้านล่างตรงกับโค้ดจัดการคำขอ โดย message ใช้ข้อความแทน และเซิร์ฟเวอร์เป็นผู้ส่งข้อความจริง
{
"error" : {
"message" : "<server-generated message>" ,
"type" : "invalid_request_error" ,
"code" : 400
}
} Streaming ตั้ง stream: true เพื่อรับ Server-Sent Events (SSE) stream แต่ละเหตุการณ์มีส่วนหนึ่งของการตอบกลับ
Python cURL TypeScript fetch (SSE)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from openai import OpenAI
client = OpenAI(
base_url="https://api.bazaarlink.ai/v1" ,
api_key="sk-bl-YOUR_API_KEY" ,
)
stream = client.chat.completions.create(
model="anthropic/claude-sonnet-4.6" ,
messages=[{"role" : "user" , "content" : "Count to 10 slowly." }],
stream=True ,
)
for chunk in stream:
content = chunk.choices[0 ].delta.content
if content:
print (content, end="" , flush=True )
⌄ ดูทั้งหมด 17 บรรทัดรูปแบบ SSE data: {"id" :"85e6f35c71a31f19-SJC" ,"choices" :[{"delta" :{"content" :"Hello" },"index" :0}]}
data: {"id" :"85e6f35c71a31f19-SJC" ,"choices" :[{"delta" :{"content" :" world" },"index" :0}]}
data: {"id" :"85e6f35c71a31f19-SJC" ,"choices" :[{"delta" :{},"finish_reason" :"stop" ,"index" :0}],"usage" :{"prompt_tokens" :10,"completion_tokens" :4,"total_tokens" :14}}
data: [DONE]การใช้งานใน streaming
เมื่อ streaming ข้อมูลการใช้งานจะถูกส่งคืนในชิ้นสุดท้ายก่อนข้อความ [DONE] พร้อมอาร์เรย์ choices ที่มี delta ว่างและ finish_reason: "stop"
Keep-alive และ chunk สุดท้าย สตรีมอาจมีบรรทัดคอมเมนต์ SSE และ event unknown หรือ ping เพื่อ keep-alive ให้ข้ามและ parse data frame; data frame สุดท้ายอาจมี usage ก่อน data: [DONE]
: keepalive <- SSE comment line — ignore, do NOT JSON.parse
data: {"id" :"85e6f35c71a31f19-SJC" ,"choices" :[{"delta" :{"content" :"Hi" },"index" :0}]}
data: {"id" :"85e6f35c71a31f19-SJC" ,"choices" :[{"delta" :{},"finish_reason" :"stop" ,"index" :0}],"usage" :{...}}
data: [DONE]การยกเลิกสตรีม คำขอ streaming สามารถยกเลิกได้ด้วยการปิดการเชื่อมต่อฝั่งไคลเอนต์ — เช่น เรียก AbortController.abort() หรือปิดออบเจ็กต์ stream ทันทีที่ BazaarLink ได้รับสัญญาณยกเลิก จะหยุดส่งต่อ chunk ถัดไปและยกเลิกคำขอที่ส่งไปยังผู้ให้บริการ
TypeScript Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import OpenAI from "openai" ;
const client = new OpenAI ({
baseURL : "https://api.bazaarlink.ai/v1" ,
apiKey : "sk-bl-YOUR_API_KEY" ,
});
const controller = new AbortController ();
const stream = await client.chat .completions .create (
{
model : "anthropic/claude-sonnet-4.6" ,
messages : [{ role : "user" , content : "Write a long story." }],
stream : true ,
},
{ signal : controller.signal }
);
for await (const chunk of stream) {
const content = chunk.choices [0 ]?.delta ?.content ;
if (content) process.stdout .write (content);
}
controller.abort ();
⌄ ดูทั้งหมด 25 บรรทัดสตรีมที่ถูกขัดจังหวะไม่มีค่าใช้จ่าย
ถ้าสตรีมจบลงก่อนที่ chunk usage สุดท้ายจะมาถึง — รวมถึงกรณีที่ไคลเอนต์ยกเลิกเอง — จะไม่มีข้อมูลจำนวนโทเค็นที่เชื่อถือได้สำหรับคำขอนั้น BazaarLink จึงคืนเงินที่กันไว้เต็มจำนวน คุณจะไม่ถูกเรียกเก็บเงินสำหรับเนื้อหาที่ส่งถึงไคลเอนต์ไปแล้วก่อนการยกเลิก
ไม่รับประกันว่าผู้ให้บริการจะหยุดทันที
การปิดการเชื่อมต่อทำให้ BazaarLink หยุดส่งต่อและหยุดคิดค่าใช้จ่ายโทเค็นถัดไปทันที แต่ผู้ให้บริการต้นทางจะหยุดการสร้างข้อมูลบนเซิร์ฟเวอร์ของตนเองทันทีที่การเชื่อมต่อขาดหรือไม่นั้น ขึ้นอยู่กับผู้ให้บริการรายนั้น ๆ — บางรายอาจยังประมวลผลต่ออีกสักครู่หลังจากตัดการเชื่อมต่อ
ข้อผิดพลาดกลางสตรีม เฟรม error ไม่มีฟิลด์ choices
หากเกิดความล้มเหลวหลังจากที่ streaming เริ่มไปแล้ว (เช่น การเชื่อมต่อ upstream หลุด) คุณจะได้รับ SSE data frame รูปแบบ {error:{message,type,code}} แทนที่ {choices:[...]} ตามปกติ — โดยไม่มีการเปลี่ยนสถานะ HTTP เนื่องจาก header ถูกส่งไปแล้ว ให้ตรวจสอบ error key ก่อนอ่าน choices[0].delta และจะเรียกเก็บเงินเฉพาะโทเค็นที่ stream ไปแล้วเท่านั้น (ใช้การเรียกเก็บเงินบางส่วน)
data: {"id" :"85e6f35c71a31f19-SJC" ,"choices" :[{"delta" :{"content" :"The capital of " },"index" :0}]}
data: {"error" :{"message" :"The request could not be completed." ,"type" :"upstream_error" ,"code" :502}}
data: [DONE]Embeddings Embeddings คือการแทนค่าตัวเลขของข้อความที่จับความหมายเชิงความหมาย (semantic) — แปลงข้อความเป็นเวกเตอร์ (ชุดตัวเลข) ที่นำไปใช้กับงาน machine learning ได้หลากหลาย BazaarLink มี endpoint แบบรวมศูนย์ที่รองรับ OpenAI Embeddings API ให้คุณเรียกใช้โมเดล embedding จากหลายผู้ให้บริการผ่านอินเทอร์เฟซเดียว
response ของ embedding ใช้ request ID แบบ opaque ของ BazaarLink ที่ตรงกับ x-request-id ใช้ร่วมกับ GET /v1/generation response แบบ non-streaming จะส่ง ID เดียวกันใน x-generation-id ด้วย usage.cost คือจำนวนเงิน USD ที่เรียกเก็บจากลูกค้าสำหรับ request นี้ สถิติอาจพร้อมใช้งานหลังเสร็จสิ้นไม่กี่วินาที หากได้ 404 ให้ลองซ้ำช่วงสั้นๆ
Embeddings คืออะไร? Embeddings แปลงข้อความเป็นเวกเตอร์มิติสูง โดยข้อความที่มีความหมายใกล้เคียงกันจะอยู่ใกล้กันในปริภูมิเวกเตอร์ — เช่น "cat" กับ "kitten" จะมี embedding ที่คล้ายกัน แต่ "cat" กับ "airplane" จะอยู่ห่างกันมาก การแทนค่าแบบเวกเตอร์นี้ทำให้เครื่องจักรเข้าใจความสัมพันธ์ระหว่างข้อความ ซึ่งเป็นรากฐานของแอปพลิเคชัน AI จำนวนมาก
กรณีการใช้งานทั่วไป RAG (รุ่นที่ดึงข้อมูลเพิ่ม) สร้างระบบที่ดึงบริบทที่เกี่ยวข้องจากฐานความรู้ก่อนสร้างคำตอบ — embeddings ช่วยหาเอกสารที่เกี่ยวข้องที่สุดเพื่อใส่ในบริบทของ LLM
การค้นหาเชิงความหมาย (Semantic Search) แปลงเอกสารและคำค้นหาเป็น embeddings แล้วหาเอกสารที่เกี่ยวข้องที่สุดด้วยความคล้ายคลึงของเวกเตอร์ — เข้าใจความหมายแทนที่จะจับคู่แค่คำสำคัญ ให้ผลลัพธ์ดีกว่าการค้นหาด้วยคำสำคัญ
ระบบแนะนำ สร้าง embeddings สำหรับสินค้า บทความ วิดีโอ และความชอบของผู้ใช้เพื่อแนะนำรายการที่คล้ายกัน — การเปรียบเทียบเวกเตอร์หารายการที่เกี่ยวข้องเชิงความหมายได้แม้ไม่มีคำสำคัญร่วมกัน
การจัดกลุ่มและจำแนกประเภท จัดกลุ่มเอกสารที่คล้ายกันหรือจำแนกข้อความโดยวิเคราะห์รูปแบบ embedding — เอกสารที่มี embedding คล้ายกันมักอยู่หัวข้อหรือหมวดหมู่เดียวกัน
ตรวจจับเนื้อหาซ้ำ หาเนื้อหาที่ซ้ำหรือใกล้เคียงกันโดยเปรียบเทียบความคล้ายคลึงของ embedding — ใช้ได้แม้เนื้อหาถูกเขียนใหม่ด้วยถ้อยคำต่างกัน
ตรวจจับความผิดปกติ ระบุเนื้อหาที่ผิดปกติหรือหลุดกรอบโดยหา embedding ที่เบี่ยงเบนไปจากรูปแบบทั่วไปของชุดข้อมูลอย่างมีนัยสำคัญ
POST /v1/embeddings
Note
หากแหล่ง upstream ไม่รองรับโมเดล embeddings ที่ร้องขอ คำขออาจลองใช้แหล่งอื่นที่พร้อมใช้งานได้ หากไม่มีแหล่งที่รองรับ คำขอจะได้รับข้อผิดพลาด
พารามิเตอร์ modelจำเป็น
string
โมเดล embedding ที่จะใช้ เช่น "openai/text-embedding-3-small"
inputจำเป็น
string | string[] | ContentItem[]
ข้อความที่จะแปลงเป็น embedding — สตริงเดียว, อาร์เรย์ของสตริงสำหรับเรียกแบบ batch ครั้งเดียว หรือ (สำหรับโมเดลที่รองรับ) อาร์เรย์ของรายการ {content:[...]} ที่ผสมส่วน text และ image_url
dimensions
integer
ขนาดเวกเตอร์ผลลัพธ์ที่ร้องขอ ใช้ได้เฉพาะกับโมเดลที่รองรับมิติแบบปรับได้ (เช่น ตระกูล OpenAI text-embedding-3) ส่งต่อไปยังผู้ให้บริการ upstream ตามเดิมและถูกละเว้นในโมเดลที่ไม่รองรับ
encoding_format
string
รูปแบบการเข้ารหัส embedding ที่ร้องขอ เช่น "float" หรือ "base64" ส่งต่อไปยังผู้ให้บริการ upstream ตามเดิม — การรองรับขึ้นอยู่กับโมเดล
provider
object
Unsupported. The entire object is ignored and removed before forwarding; it cannot select an upstream or price tier.
คำขอพื้นฐาน Python cURL TypeScript
from openai import OpenAI
client = OpenAI(
base_url="https://api.bazaarlink.ai/v1" ,
api_key="sk-bl-YOUR_API_KEY" ,
)
response = client.embeddings.create(
model="openai/text-embedding-3-small" ,
input ="The quick brown fox jumps over the lazy dog" ,
)
print (response.data[0 ].embedding)
⌄ ดูทั้งหมด 13 บรรทัดการประมวลผลแบบ Batch ส่งอาร์เรย์ของสตริงเพื่อแปลงข้อความหลายรายการเป็น embedding ในคำขอเดียว — ถูกกว่าและเร็วกว่าการเรียกทีละข้อความ
Python cURL TypeScript
response = client.embeddings.create(
model="openai/text-embedding-3-small" ,
input =[
"Machine learning is a subset of artificial intelligence" ,
"Deep learning uses neural networks with multiple layers" ,
"Natural language processing enables computers to understand text" ,
],
)
for i, item in enumerate (response.data):
print (f"Embedding {i} : {len (item.embedding)} dimensions" )
⌄ ดูทั้งหมด 11 บรรทัดอินพุตหลายรูปแบบ (รูปภาพ + ข้อความ) โมเดลที่รองรับอินพุตรูปภาพ (output_modalities มี "embeddings" และ inputModalities มี "image") รับรายการอินพุตรูปแบบ {content:[{type:"text",...}, {type:"image_url",...}]} ทำให้คุณแปลงรูปภาพเดี่ยว ๆ หรือร่วมกับข้อความเป็น embedding ได้
ขึ้นอยู่กับโมเดล
มีเพียงบางโมเดล embedding เท่านั้นที่รับอินพุตรูปภาพ — ตรวจสอบโมดัลิตีที่โมเดลรองรับในหน้า Models ก่อนส่งเนื้อหา image_url โมเดลที่รองรับเฉพาะข้อความจะปฏิเสธรูปแบบนี้
Python cURL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import requests
response = requests.post(
"https://api.bazaarlink.ai/v1/embeddings" ,
headers={
"Authorization" : "Bearer sk-bl-YOUR_API_KEY" ,
"Content-Type" : "application/json" ,
},
json={
"model" : "google/gemini-embedding-2-preview" ,
"input" : [{
"content" : [
{"type" : "text" , "text" : "A scenic boardwalk through a green meadow" },
{"type" : "image_url" , "image_url" : {"url" : "https://example.com/boardwalk.jpg" }},
]
}],
"encoding_format" : "float" ,
},
)
embedding = response.json()["data" ][0 ]["embedding" ]
print (f"Embedding dimension: {len (embedding)} " )
⌄ ดูทั้งหมด 22 บรรทัดการค้นหาโมเดล Embedding ไม่มี endpoint สำหรับแสดงรายการโมเดล embedding โดยเฉพาะ — เรียก GET /v1/models แล้วกรองฝั่งไคลเอนต์หารายการที่ output_modalities มี "embeddings" หรือดูที่หน้า Models
ข้อจำกัด ไม่รองรับ streaming — embeddings จะถูกส่งกลับเป็นการตอบสนองแบบสมบูรณ์เสมอ ต่างจาก chat completions แต่ละโมเดลมีความยาวอินพุตสูงสุด ข้อความที่เกินขีดจำกัดจะถูกตัดหรือปฏิเสธที่ upstream embeddings สำหรับอินพุตเดียวกันมีความแน่นอน (deterministic) — ไม่มี temperature หรือความสุ่มเข้ามาเกี่ยวข้อง แนวทางปฏิบัติที่ดี เลือกโมเดลตามความสมดุลระหว่างความเร็ว/คุณภาพ/ต้นทุน — โมเดลขนาดเล็ก (เช่น qwen/qwen3-embedding-4b) ถูกกว่าและเร็วกว่า ส่วนโมเดลขนาดใหญ่ (เช่น openai/text-embedding-3-large) มักให้ผลลัพธ์แม่นยำกว่า รวมข้อความหลายรายการไว้ในคำขอเดียวแทนการเรียกทีละข้อความ — ลดจำนวนรอบการเรียกและ overhead แคชผลลัพธ์ไว้ — embedding ของอินพุตเดียวกันจะไม่เปลี่ยนแปลง ควรเก็บไว้แทนการสร้างใหม่ เปรียบเทียบด้วย cosine similarity แทน Euclidean distance — ไม่ขึ้นกับสเกลและเหมาะกับเวกเตอร์มิติสูงกว่า ระวังความยาว context ของแต่ละโมเดล — เอกสารยาวอาจต้องแบ่งเป็นส่วน (chunking) ก่อนแปลงเป็น embedding พารามิเตอร์ พารามิเตอร์การสุ่มตัวอย่างกำหนดกระบวนการสร้างโทเค็น BazaarLink ส่งพารามิเตอร์ที่รองรับไปยังผู้ให้บริการ upstream; พารามิเตอร์ที่ไม่รองรับจะถูกเพิกเฉย
พารามิเตอร์การสุ่มตัวอย่าง ส่งต่อล้วนๆ — ไม่มีค่าเริ่มต้นในเครื่อง
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
temperature
number
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
top_p
number
มวลความน่าจะเป็นการสุ่มตัวอย่าง Nucleus ค่าเริ่มต้น: 1
top_k
integer
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
frequency_penalty
number
ลงโทษโทเค็นที่ซ้ำ ช่วง: [-2, 2] ค่าเริ่มต้น: 0
presence_penalty
number
ลงโทษโทเค็นตามการมีอยู่ ช่วง: [-2, 2] ค่าเริ่มต้น: 0
repetition_penalty
number
ลดการซ้ำโทเค็นจากอินพุต ช่วง: (0, 2] ค่าเริ่มต้น: 1
min_p
number
ความน่าจะเป็นขั้นต่ำเทียบกับโทเค็นสูงสุด ช่วง: [0, 1] ค่าเริ่มต้น: 0
top_a
number
top-P แบบไดนามิกตามโทเค็นที่มีความน่าจะเป็นสูงสุด ช่วง: [0, 1] ค่าเริ่มต้น: 0
seed
integer
ค่า seed จำนวนเต็มสำหรับการสุ่มตัวอย่างแบบกำหนดได้ ไม่รับประกันสำหรับทุกโมเดล
max_tokens
integer
จำนวนโทเค็นสูงสุดที่จะสร้าง
n
integer
จำนวน completions ที่จะสร้าง ค่าเริ่มต้น: 1
logit_bias
object
แมป ID โทเค็นกับค่าอคติ [-100, 100] ที่เพิ่มก่อนการสุ่มตัวอย่าง ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
logprobs
boolean
ส่งคืนค่า log probabilities ของแต่ละโทเค็นเอาต์พุต ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
top_logprobs
integer
จำนวนโทเค็นที่น่าจะเป็นไปได้มากที่สุดที่จะส่งคืนต่อตำแหน่ง (ต้องใช้ logprobs: true) ช่วง: 0–20 ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
response_format
object
บังคับเอาต์พุต JSON ที่มีโครงสร้าง ดูส่วน Structured Output
structured_outputs
boolean
ขอผลลัพธ์ที่สอดคล้องกับ JSON schema อย่างเคร่งครัดกับผู้ให้บริการที่รองรับ ส่งต่อตามเดิม
reasoning
object
การตั้งค่า reasoning/thinking เฉพาะผู้ให้บริการ ส่งต่อตามเดิม
reasoning_effort
string
ระดับความพยายามในการ reasoning สไตล์ OpenAI ซีรีส์ o: "low", "medium" หรือ "high" ส่งต่อตามเดิม
include_reasoning
boolean
true จะส่งเนื้อหาความคิดกลับใน message.reasoning (delta.reasoning เมื่อสตรีม); false ปิดการคิดสำหรับโมเดลที่คิดโดยค่าเริ่มต้น (ดูหัวข้อ reasoning) จึงไม่มีการคิดเงินค่าคิด หากไม่ส่ง reasoning_effort, reasoning หรือ thinking จะมีเพียงโมเดลเหล่านั้นที่คิดและส่งกลับโดยค่าเริ่มต้น โมเดลอื่นส่งกลับเมื่อร้องขอเท่านั้น
stop
string | string[]
ลำดับหยุด — การสร้างจะหยุดเมื่อพบ
tools
Tool[]
รายการเครื่องมือ (ฟังก์ชัน) ที่โมเดลอาจเรียกใช้
tool_choice
string | object
ควบคุมการใช้เครื่องมือ: "auto", "none" หรือเครื่องมือเฉพาะ
parallel_tool_calls
boolean
เปิดใช้งานการเรียกฟังก์ชันแบบขนานเมื่อมีเครื่องมือ ค่าเริ่มต้น: true ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
เครดิต สอบถามยอดเครดิตปัจจุบันและการใช้งาน API ตลอดอายุการใช้งาน
GET /v1/credits
Auth
Requires Bearer token (คีย์ API มาตรฐาน sk-bl-...)
ตัวอย่างคำขอ cURL Python
curl https://api.bazaarlink.ai/v1/credits \
-H "Authorization: Bearer sk-bl-YOUR_KEY" การตอบสนอง {
"data" : {
"total_credits" : 100.00 ,
"total_usage" : 12.34
}
} Errors: 401 (คีย์ missing/invalid), 403 (ผู้ใช้ที่ถูกระงับ)
รายละเอียดรุ่น ใช้ BazaarLink request ID แบบ opaque จาก response id หรือ header x-request-id กับ GET /v1/generation; response non-streaming มี ID เดียวกันใน x-generation-id สถิติอาจปรากฏหลังเสร็จไม่กี่วินาที หากได้ 404 ให้ลองซ้ำช่วงสั้นๆ
GET /v1/generation?id=<generation-id>
Auth
Requires Bearer token (คีย์ API มาตรฐาน) พารามิเตอร์การสืบค้นที่จำเป็น: id
ตัวอย่างคำขอ curl "https://api.bazaarlink.ai/v1/generation?id=BAZAARLINK_REQUEST_ID" \
-H "Authorization: Bearer sk-bl-YOUR_KEY" การตอบสนอง 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
"data" : {
"id" : "85e6f35c71a31f19-SJC" ,
"model" : "openai/gpt-4o" ,
"provider" : "bazaarlink" ,
"created_at" : "2026-04-20T10:00:00.000Z" ,
"app_name" : "MyApp" ,
"finish_reason" : "stop" ,
"status" : 200 ,
"duration_ms" : 1234 ,
"first_token_ms" : 234 ,
"throughput" : 45.6 ,
"usage" : {
"prompt_tokens" : 100 ,
"completion_tokens" : 200 ,
"total_tokens" : 300 ,
"prompt_tokens_details" : { "cached_tokens" : 50 } ,
"completion_tokens_details" : { "reasoning_tokens" : 30 } ,
"cost" : 0.00123
} ,
"cost_breakdown" : {
"subtotal" : 0.00123 ,
"cache_discount" : 0.00015 ,
"total" : 0.00108
}
}
}
⌄ ดูทั้งหมด 27 บรรทัดข้อผิดพลาด: 400 (ไม่มี ID), 401 (รับรองความถูกต้อง), 404 (ไม่พบรุ่น)
API ข้อมูลสำคัญ Query ระดับขีดจำกัดอัตราของคีย์ API ปัจจุบันและตัวนับการใช้งานแบบรวม (รูปแบบการตอบกลับเป็นไปตามแบบแผน API คีย์ข้อมูลอุตสาหกรรมทั่วไป)
GET /v1/key
Auth
Requires Bearer token (คีย์ API มาตรฐาน)
การตอบสนอง 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"data" : {
"label" : "Production Key" ,
"limit" : null ,
"limit_remaining" : 100.00 ,
"limit_reset" : null ,
"expires_at" : null ,
"is_free_tier" : false ,
"is_management_key" : false ,
"is_provisioning_key" : false ,
"usage" : 12.34 ,
"usage_daily" : 0.12 ,
"usage_weekly" : 0.45 ,
"usage_monthly" : 1.23 ,
"requests" : 1234 ,
"requests_daily" : 10 ,
"requests_weekly" : 50 ,
"requests_monthly" : 200 ,
"rate_limit" : { "requests" : 600 , "interval" : "1m" , "note" : "Paid-tier rate limit." }
}
}
⌄ ดูทั้งหมด 21 บรรทัดNote
is_free_tier = true เมื่อยอดเครดิต < $10 Windows อยู่ใน UTC: รายวัน = วันปัจจุบัน รายสัปดาห์ = จันทร์–อาทิตย์ รายเดือน = 1st–EOM เมื่อคีย์มีการตั้งค่าขีดจำกัดการใช้จ่ายต่อคีย์ (ผ่านพารามิเตอร์ขีดจำกัดบนคีย์ creation/update) Limit / Limit_remaining / Limit_reset สะท้อนถึงขีดจำกัดนั้นและการใช้งานของระยะเวลาที่ตรงกัน มิฉะนั้นขีดจำกัดจะเป็นโมฆะและขีดจำกัดที่เหลือจะกลับไปอยู่ที่ยอดเครดิตในบัญชีของคุณ หมดอายุ_at คือเวลาหมดอายุของคีย์ (ค่าว่างหากไม่มี) is_management_key และ is_provisioning_key เป็นนามแฝงสำหรับแนวคิดเดียวกัน — เป็นจริงทั้งคู่สำหรับคีย์การจัดการ
BYOK
BazaarLink ไม่มีโปรแกรม Bring-your-own-key (BYOK) ดังนั้นจุดสิ้นสุดนี้จึงไม่ส่งคืนฟิลด์ byok_usage ใดๆ
Errors: 401 (auth), 404 (ผู้ใช้หายไป — หายาก)
รหัสข้อผิดพลาด Error รูปแบบการตอบสนอง รูปแบบ error envelope แตกต่างตาม endpoint ใช้ HTTP status และ error.type เมื่อมี error.code อาจเป็น string หรือ numeric status และอาจไม่มี; error.message ใช้แสดงผลเท่านั้น
{
"error" : {
"message" : "Insufficient credits. Please top up to continue." ,
"type" : "invalid_request_error" ,
"code" : "insufficient_credits"
}
} HTTP สถานะและข้อผิดพลาดรหัส รูปแบบ error envelope แตกต่างตาม endpoint ใช้ HTTP status และ error.type เมื่อมี error.code อาจเป็น string หรือ numeric status และอาจไม่มี; error.message ใช้แสดงผลเท่านั้น
424การพึ่งพาล้มเหลว คีย์ BYOK ที่คุณตั้งค่าเองถูกผู้ให้บริการ upstream ปฏิเสธ โปรดตรวจสอบหรือเปลี่ยนคีย์ในการตั้งค่า BYOK ข้อผิดพลาดนี้จะแสดงเฉพาะในโหมด strict
400คำขอไม่ถูกต้อง คำขอมีรูปแบบไม่ถูกต้อง อาร์เรย์ข้อความว่างเปล่า หรือช่องที่ต้องกรอกหายไป
คีย์
401ไม่ได้รับอนุญาต API หายไป ไม่ถูกต้อง หรือปิดใช้งาน
402ต้องชำระเงิน เครดิตบัญชีไม่เพียงพอ ถึงขีดจำกัดการใช้จ่ายต่อคีย์แล้ว หรือเกินขีดจำกัดงบประมาณ monthly/weekly
403ห้าม บัญชีถูกระงับหรือไม่ได้รับอนุญาต
404ไม่พบ Requested model, generation, key, or other resource does not exist
409ความขัดแย้ง Resource is not in the required state, such as an incomplete video job
410ไปแล้ว Requested model has been retired and must be replaced
413เนื้อหาใหญ่เกินไป เนื้อหาคำขอเกิน 10 MB; ลดขนาดเนื้อหาหรือแยกคำขอ
416Range ไม่น่าพอใจ Requested byte range is invalid for generated video content
429คำขอมากเกินไป Rate เกินขีดจำกัด; ตรวจสอบส่วนหัว Retry-After ก่อนที่จะลองอีกครั้ง
432โควตาฟรีหมดแล้ว เอนด์พอยต์ที่เข้ากันได้กับ Tavily (/v1/search, /v1/extract, /v1/crawl, /v1/map): โควตาการค้นหาฟรีถูกใช้หมดแล้ว หรือยอดคงเหลือเป็นศูนย์หรือติดลบ โปรดเติมเครดิตเพื่อใช้งานต่อ เนื้อหาการตอบกลับอยู่ในรูปแบบ Tavily: {"detail":{"error":"..."}}
500ข้อผิดพลาดเซิร์ฟเวอร์ ข้อผิดพลาดภายใน BazaarLink
502เกตเวย์ไม่ถูกต้อง ไม่มีแหล่ง upstream ที่ประมวลผลคำขอได้ คำขอจะได้รับข้อผิดพลาด
503บริการไม่พร้อมใช้งาน ไม่มีการกำหนดค่าผู้ให้บริการอัปสตรีมสำหรับรุ่นนี้ ติดต่อผู้ดูแลระบบ
504เกตเวย์หมดเวลา Upstream connection or stream stalled and timed out
รหัสการเรียกเก็บเงินที่เครื่องอ่านได้ A 402 can represent different controls. Use these stable codes to choose the correct action.
byok_key_invalidคีย์ BYOK ที่คุณตั้งค่าเองถูกผู้ให้บริการ upstream ปฏิเสธ โปรดตรวจสอบหรือเปลี่ยนคีย์ในการตั้งค่า BYOK ข้อผิดพลาดนี้จะแสดงเฉพาะในโหมด strict
budget_cap_reachedA weekly or monthly budget cap was reached; raise or reset the cap.
credit_limit_exceededA monthly-billing organization's credit line was exhausted; contact billing.
insufficient_creditsThe prepaid balance is insufficient; add credits.
spend_limit_exceededThe API key reached its daily, weekly, or monthly spend limit.
capacity_unavailableThis model is temporarily at capacity. Retry shortly; the Retry-After header says how long to wait.
Stable error.code catalog These string codes are emitted by public inference and media paths. Branch on the string code when present; the HTTP status remains the broad failure class.
รุ่นและจุดสิ้นสุด
การค้นหาโมเดล วงจรการใช้งาน ราคา รูปแบบ และข้อผิดพลาดความเข้ากันได้ของอุปกรณ์ปลายทาง
unknown_model400
invalid_model_id400
model_not_found404
model_retired410
model_endpoint_mismatch400
embedding_on_chat_endpoint400
model_not_priced400
invalid_modality_for_model400
คำขอและความปลอดภัย
พารามิเตอร์ บริบท เครื่องมือ สคีมา และการปฏิเสธความปลอดภัยของเนื้อหาไม่ถูกต้อง
missing_required_field400
unsupported_param400
max_tokens_invalid400
context_too_long400
tool_use_unsupported400
malformed_tool_messages400
invalid_response_format_schema400
invalid_tools_definition400
content_moderation403
content_filter403
unknown_4xx400
การสร้างและแก้ไขภาพ
ข้อผิดพลาดอินพุตรูปภาพ การแก้ไขหลายส่วน เอาต์พุต และข้อผิดพลาดไปป์ไลน์รูปภาพ
invalid_image_url400
input_images_not_supported400
invalid_content_type400
mask_not_supported400
unsupported_response_format400
missing_prompt400
missing_image400
too_many_images400
invalid_image_type400
image_too_large400
invalid_n400
pipeline_error502
no_images502
การกำหนดเส้นทางอัปสตรีม
การเชื่อมต่อผู้ให้บริการที่ผ่านการฆ่าเชื้อ การรับรองความถูกต้อง การควบคุมปริมาณ และข้อผิดพลาดด้านความพร้อมใช้งาน
upstream_unreachable502
upstream_auth_failed502
upstream_rate_limited429
capacity_unavailable429
upstream_unavailable502/503
byok_key_invalid424
การตรวจสอบเนื้อหา คำขอทั้งหมดจะถูกตรวจสอบโดยอัตโนมัติก่อนส่งไปยังโมเดล คำขอที่ละเมิดนโยบายการใช้งานของเราจะถูกปฏิเสธก่อนถึงโมเดล และจะได้รับข้อผิดพลาด 403
หมวดหมู่เนื้อหาที่จะถูกบล็อก การตรวจสอบเป็นไปตามนโยบายการใช้งานที่ยอมรับได้ (Acceptable Use Policy) ของเรา และจะบล็อกเนื้อหาในหมวดหมู่ต่อไปนี้เป็นหลัก:
เนื้อหาการแสวงหาประโยชน์ทางเพศ การขู่ใช้ความรุนแรง คำแนะนำในการดำเนินการที่ผิดกฎหมาย เนื้อหาที่เกี่ยวข้องกับอันตรายทางชีวภาพ รูปแบบการตอบกลับ 403 คำขอที่ถูกบล็อกโดยการตรวจสอบจะได้รับข้อผิดพลาดในรูปแบบนี้:
{
"error" : {
"message" : "Your prompt was blocked by content moderation." ,
"type" : "invalid_request_error" ,
"code" : "content_filter"
}
} คำขอที่ถูกบล็อกจะไม่ถูกเรียกเก็บเงิน — คุณจะไม่ถูกเรียกเก็บเงินสำหรับคำขอที่ถูกปฏิเสธ
การอุทธรณ์กรณีตรวจจับผิดพลาด หากคุณเชื่อว่าคำขอถูกบล็อกอย่างไม่ถูกต้อง โปรดติดต่อฝ่ายสนับสนุนพร้อมระบุเวลาของคำขอ และ (หากสะดวก) request id เราจะตรวจสอบให้
ความเป็นส่วนตัว คำขอทุกรายการจะถูกตรวจสอบเนื้อหาโดยอัตโนมัติ
คำขอที่พบว่าละเมิดนโยบายจะถูกเก็บเนื้อหาไว้เป็นหลักฐานการปฏิบัติตามข้อกำหนด
คำขออื่น ๆ จะไม่มีการเก็บเนื้อหาพรอมต์แบบเต็ม
อัตราจำกัด งบประมาณ และเบรกฉุกเฉิน These controls can reject an otherwise valid request and require different recovery actions.
การควบคุม
HTTP
จะระบุได้อย่างไร
อัตราการร้องขอจำกัด 429string code หรือ numeric code 429; ใช้ header Retry-After และ X-RateLimit-*
บล็อกการลงโทษจำกัดอัตรา 429รหัสตัวเลข 429 และข้อความจำกัดชั่วคราว ใช้ลองใหม่หลังจาก
Global ใช้เบรกฉุกเฉิน 503รหัสตัวเลข 503 ข้อความจำกัดการใช้จ่ายทั่วโลก และลองอีกครั้งหลังจากผ่านไป 30 หรือ 300 วินาที
Scoped spend brake 429Numeric code 429 and a spend circuit-breaker message naming the scope.
การควบคุมการเรียกเก็บเงินและงบประมาณ 402ใช้รหัสสตริงการเรียกเก็บเงินแบบคงที่ตามรายการด้านบน
รูปแบบ error envelope แตกต่างตาม endpoint ใช้ HTTP status และ error.type เมื่อมี error.code อาจเป็น string หรือ numeric status และอาจไม่มี; error.message ใช้แสดงผลเท่านั้น
สถานะทรัพยากรวิดีโอและสื่อ Video validation commonly returns numeric code 400. Missing jobs return 404, retired models 410, unfinished video content 409, and invalid video byte ranges 416.
ลองนโยบายอีกครั้ง Retry only failures that may recover without changing the request. Honor Retry-After or use exponential backoff with jitter. Do not stack SDK and manual retries.
ลองอีกครั้งโดยถอยกลับ
429, 502, 503, and 504. Check the original generation job before creating another after an ambiguous network failure.
Fix ก่อนลองอีกครั้ง
400, 401, 402, 403, 404, 409, 410, 413, and 416. Fix the request, credentials, balance, permissions, resource state, or Range header first.
การจัดการข้อผิดพลาด Python TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import random
import time
from openai import OpenAI, APIStatusError
client = OpenAI(
base_url="https://api.bazaarlink.ai/v1" ,
api_key="sk-bl-YOUR_API_KEY" ,
max_retries=0 ,
)
RETRYABLE = {429 , 502 , 503 , 504 }
for attempt in range (5 ):
try :
response = client.chat.completions.create(
model="openai/gpt-4o" ,
messages=[{"role" : "user" , "content" : "Hello!" }],
)
break
except APIStatusError as error:
if error.status_code not in RETRYABLE or attempt == 4 :
raise
retry_after = error.response.headers.get("Retry-After" )
delay = (
float (retry_after)
if retry_after
else min (8 , 0.5 * (2 ** attempt)) + random.uniform(0 , 0.25 )
)
time.sleep(delay)
⌄ ดูทั้งหมด 29 บรรทัดรูปแบบข้อผิดพลาด Streaming Errors ที่เกิดขึ้นก่อนที่จะสตรีมโทเค็นใดๆ จะส่งกลับการตอบสนองข้อผิดพลาด HTTP มาตรฐานพร้อมเนื้อหา JSON
หลังจาก stream เริ่มแล้ว HTTP response จะเป็น 200 อยู่แล้ว ให้ parse SSE data frame ทุกเฟรม และถือว่า error ระดับบนสุด หรือ choices[0].finish_reason === "error" คือ response ที่ล้มเหลวและไม่สมบูรณ์
หาก stream ล้มเหลวหลังจากเริ่มแล้ว BazaarLink อาจส่ง SSE event สุดท้ายที่มี error object ระดับบนสุด ตามด้วย data: [DONE] ให้ถือว่า response ไม่สมบูรณ์ และอย่าใช้ output บางส่วนเป็นผลลัพธ์ที่เสร็จสมบูรณ์
data: {"error":{"message":"The request could not be completed.","type":"upstream_error","code":502}}
data: [DONE]
// Branch on error.code; error.type can vary by failure path.การจัดการเวอร์ชัน BazaarLink เปิดให้ใช้ API path ที่เสถียรเพียงเส้นทางเดียวคือ /v1 — ไม่มีเวอร์ชันที่ผูกกับวันที่หรือ header เวอร์ชันให้ต้องจัดการ API มีการพัฒนาอย่างต่อเนื่องแทนที่จะออกเป็นรุ่นที่มีหมายเลข
การเปลี่ยนแปลงที่ไม่กระทบการทำงานเดิม สิ่งเหล่านี้จะถูกปล่อยออกมาโดยไม่แจ้งล่วงหน้า:
endpoint ใหม่ โมเดลใหม่ที่เพิ่มเข้าแคตตาล็อก พารามิเตอร์คำขอที่เป็นตัวเลือกใหม่ ฟิลด์การตอบกลับใหม่ schema ใหม่ที่มีคุณสมบัติเป็นตัวเลือก รหัสสถานะ/ข้อผิดพลาดของการตอบกลับเพิ่มเติม เขียนไคลเอนต์แบบป้องกันไว้ก่อน
ให้ข้ามฟิลด์การตอบกลับที่ไม่รู้จัก และอย่าให้ล้มเหลวเมื่อพบค่าที่ไม่รู้จักในฟิลด์ประเภท enum — ค่าใหม่จะถูกเพิ่มเข้ามาเมื่อแคตตาล็อกและฟีเจอร์ขยายตัว
การเปลี่ยนแปลงที่กระทบการทำงานเดิม สิ่งเหล่านี้เกิดขึ้นได้ยาก และครอบคลุม:
การลบหรือเปลี่ยนชื่อ endpoint พารามิเตอร์ หรือฟิลด์การตอบกลับ การเปลี่ยนชนิดของฟิลด์ การทำให้พารามิเตอร์ที่เป็นตัวเลือกกลายเป็นบังคับ เมื่อเกิดขึ้นจริง การเปลี่ยนแปลงที่กระทบการทำงานเดิมจะใช้กับ endpoint เฉพาะเจาะจง ไม่ใช่ทั้งหมดของ /v1 — ไม่มีการเลื่อนเวอร์ชันครั้งเดียวที่จะทำให้ทุกการเชื่อมต่อพังพร้อมกัน เรายังไม่ได้เผยแพร่ changelog อย่างเป็นทางการที่มีแท็ก Breaking (ดู "ติดตามความเคลื่อนไหว" ด้านล่าง) — สำหรับสิ่งที่สำคัญต่อการเชื่อมต่อของคุณ กรุณาติดต่อ Support ก่อนที่จะพึ่งพาพฤติกรรมที่ไม่มีเอกสารรองรับ
นโยบายการเลิกใช้งาน เหตุการณ์ "กระทบการทำงานเดิม" ตามปกติเพียงอย่างเดียวที่คุณควรคาดการณ์ไว้คือ โมเดลแต่ละตัวจะถูกเลิกใช้เมื่อผู้ให้บริการ upstream เลิกสนับสนุน ตรวจสอบสถานะปัจจุบันของโมเดลได้ผ่าน GET /v1/models
GET https://api.bazaarlink.ai/v1/models
Authorization: Bearer sk-bl-YOUR_API_KEY
ติดตามความเคลื่อนไหว เรายังไม่ได้เผยแพร่ API changelog หรือ RSS feed โดยเฉพาะ ในตอนนี้ให้ตรวจสอบหน้านี้โดยตรง ติดตามสถานะของโมเดลผ่าน GET /v1/models หรือติดต่อ Support หากคุณต้องการแจ้งเตือนล่วงหน้าสำหรับการเชื่อมต่อที่สำคัญ