查询 Run 报价
curl --request POST \
--url https://api.glasser.ai/v1/runs/quote \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requests": [
{
"provider": "<string>",
"endpoint": "<string>",
"input": {},
"endpoint_version": 1
}
]
}
'import requests
url = "https://api.glasser.ai/v1/runs/quote"
payload = { "requests": [
{
"provider": "<string>",
"endpoint": "<string>",
"input": {},
"endpoint_version": 1
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
requests: [{provider: '<string>', endpoint: '<string>', input: {}, endpoint_version: 1}]
})
};
fetch('https://api.glasser.ai/v1/runs/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.glasser.ai/v1/runs/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'requests' => [
[
'provider' => '<string>',
'endpoint' => '<string>',
'input' => [
],
'endpoint_version' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.glasser.ai/v1/runs/quote"
payload := strings.NewReader("{\n \"requests\": [\n {\n \"provider\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"input\": {},\n \"endpoint_version\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.glasser.ai/v1/runs/quote")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requests\": [\n {\n \"provider\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"input\": {},\n \"endpoint_version\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.glasser.ai/v1/runs/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"requests\": [\n {\n \"provider\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"input\": {},\n \"endpoint_version\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"provider": "<string>",
"endpoint": "<string>",
"endpoint_version": 123,
"hold_usd": "<string>",
"price": {
"rule": {
"type": "flat",
"amount_usd": "<string>"
},
"display": {
"amount_usd": "<string>",
"unit": "<string>",
"cap_usd": "<string>"
},
"charges": {
"NO_RESULT": "<string>",
"PROVIDER_ERROR": "<string>",
"TIMED_OUT": "<string>",
"INTERNAL": "<string>"
}
}
}
]
}{
"error": {
"code": "validation_failed",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "unauthorized",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "forbidden",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "rate_limited",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}Run
查询 Run 报价
在运行前查询 Glasser 会为每个请求预留的金额。此免费请求不创建 Run,也不预留余额。
POST
/
v1
/
runs
/
quote
查询 Run 报价
curl --request POST \
--url https://api.glasser.ai/v1/runs/quote \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requests": [
{
"provider": "<string>",
"endpoint": "<string>",
"input": {},
"endpoint_version": 1
}
]
}
'import requests
url = "https://api.glasser.ai/v1/runs/quote"
payload = { "requests": [
{
"provider": "<string>",
"endpoint": "<string>",
"input": {},
"endpoint_version": 1
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
requests: [{provider: '<string>', endpoint: '<string>', input: {}, endpoint_version: 1}]
})
};
fetch('https://api.glasser.ai/v1/runs/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.glasser.ai/v1/runs/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'requests' => [
[
'provider' => '<string>',
'endpoint' => '<string>',
'input' => [
],
'endpoint_version' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.glasser.ai/v1/runs/quote"
payload := strings.NewReader("{\n \"requests\": [\n {\n \"provider\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"input\": {},\n \"endpoint_version\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.glasser.ai/v1/runs/quote")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requests\": [\n {\n \"provider\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"input\": {},\n \"endpoint_version\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.glasser.ai/v1/runs/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"requests\": [\n {\n \"provider\": \"<string>\",\n \"endpoint\": \"<string>\",\n \"input\": {},\n \"endpoint_version\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"provider": "<string>",
"endpoint": "<string>",
"endpoint_version": 123,
"hold_usd": "<string>",
"price": {
"rule": {
"type": "flat",
"amount_usd": "<string>"
},
"display": {
"amount_usd": "<string>",
"unit": "<string>",
"cap_usd": "<string>"
},
"charges": {
"NO_RESULT": "<string>",
"PROVIDER_ERROR": "<string>",
"TIMED_OUT": "<string>",
"INTERNAL": "<string>"
}
}
}
]
}{
"error": {
"code": "validation_failed",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "unauthorized",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "forbidden",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "rate_limited",
"message": "<string>",
"reason": "<string>",
"control": "<string>",
"retry_after_ms": 123,
"details": {}
},
"request_id": "<string>"
}- 请求: 在
requests中发送 1 到 20 项。每项包含你将发送给运行接口的provider、endpoint、input和endpoint_version。 - 响应:
data中每个请求对应一项,顺序相同。带hold_usd的项是报价;带error的项被拒绝,运行接口也会以同样的原因拒绝它。
hold_usd 是按当前价格预留的金额,不是有保证的上限。数据提供商返回的结果多于输入要求,或价格在 Run 之前发生变化时,最终费用可能更高。