const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
provider_options: {},
model: '<string>',
prompts: ['<string>'],
items: [{}],
system: '<string>',
max_tokens: 123,
temperature: 123,
input_file_id: '<string>',
requests: [
{
body: JSON.stringify({}),
custom_id: '<string>',
method: 'POST',
url: '<string>'
}
],
completion_window: '<string>',
metadata: {},
session_id: '<string>',
webhook_endpoint_id: '<string>',
debug: {
enabled: true,
return_upstream_request: true,
return_upstream_response: true,
trace: true
},
provider: {
order: ['<string>'],
only: ['<string>'],
ignore: ['<string>'],
include_alpha: true,
allow_fallbacks: true,
require_parameters: true,
required_execution_region: '<string>',
required_data_region: '<string>',
require_zero_data_retention: true,
zdr: true,
enforce_distillable_text: true,
quantizations: ['<string>'],
sort: '<string>',
max_price: {prompt: 123, completion: 123, image: 123, audio: 123, request: 123},
preferred_min_throughput: 123,
preferred_max_latency: 123
}
})
};
fetch('https://api.phaseo.app/v1/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/batches"
payload = {
"provider_options": {},
"model": "<string>",
"prompts": ["<string>"],
"items": [{}],
"system": "<string>",
"max_tokens": 123,
"temperature": 123,
"input_file_id": "<string>",
"requests": [
{
"body": {},
"custom_id": "<string>",
"method": "POST",
"url": "<string>"
}
],
"completion_window": "<string>",
"metadata": {},
"session_id": "<string>",
"webhook_endpoint_id": "<string>",
"debug": {
"enabled": True,
"return_upstream_request": True,
"return_upstream_response": True,
"trace": True
},
"provider": {
"order": ["<string>"],
"only": ["<string>"],
"ignore": ["<string>"],
"include_alpha": True,
"allow_fallbacks": True,
"require_parameters": True,
"required_execution_region": "<string>",
"required_data_region": "<string>",
"require_zero_data_retention": True,
"zdr": True,
"enforce_distillable_text": True,
"quantizations": ["<string>"],
"sort": "<string>",
"max_price": {
"prompt": 123,
"completion": 123,
"image": 123,
"audio": 123,
"request": 123
},
"preferred_min_throughput": 123,
"preferred_max_latency": 123
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.phaseo.app/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"provider_options": {},
"model": "<string>",
"prompts": [
"<string>"
],
"items": [
{}
],
"system": "<string>",
"max_tokens": 123,
"temperature": 123,
"input_file_id": "<string>",
"requests": [
{
"body": {},
"custom_id": "<string>",
"method": "POST",
"url": "<string>"
}
],
"completion_window": "<string>",
"metadata": {},
"session_id": "<string>",
"webhook_endpoint_id": "<string>",
"debug": {
"enabled": true,
"return_upstream_request": true,
"return_upstream_response": true,
"trace": true
},
"provider": {
"order": [
"<string>"
],
"only": [
"<string>"
],
"ignore": [
"<string>"
],
"include_alpha": true,
"allow_fallbacks": true,
"require_parameters": true,
"required_execution_region": "<string>",
"required_data_region": "<string>",
"require_zero_data_retention": true,
"zdr": true,
"enforce_distillable_text": true,
"quantizations": [
"<string>"
],
"sort": "<string>",
"max_price": {
"prompt": 123,
"completion": 123,
"image": 123,
"audio": 123,
"request": 123
},
"preferred_min_throughput": 123,
"preferred_max_latency": 123
}
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/batches"
payload := strings.NewReader("{\n \"provider_options\": {},\n \"model\": \"<string>\",\n \"prompts\": [\n \"<string>\"\n ],\n \"items\": [\n {}\n ],\n \"system\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"input_file_id\": \"<string>\",\n \"requests\": [\n {\n \"body\": {},\n \"custom_id\": \"<string>\",\n \"method\": \"POST\",\n \"url\": \"<string>\"\n }\n ],\n \"completion_window\": \"<string>\",\n \"metadata\": {},\n \"session_id\": \"<string>\",\n \"webhook_endpoint_id\": \"<string>\",\n \"debug\": {\n \"enabled\": true,\n \"return_upstream_request\": true,\n \"return_upstream_response\": true,\n \"trace\": true\n },\n \"provider\": {\n \"order\": [\n \"<string>\"\n ],\n \"only\": [\n \"<string>\"\n ],\n \"ignore\": [\n \"<string>\"\n ],\n \"include_alpha\": true,\n \"allow_fallbacks\": true,\n \"require_parameters\": true,\n \"required_execution_region\": \"<string>\",\n \"required_data_region\": \"<string>\",\n \"require_zero_data_retention\": true,\n \"zdr\": true,\n \"enforce_distillable_text\": true,\n \"quantizations\": [\n \"<string>\"\n ],\n \"sort\": \"<string>\",\n \"max_price\": {\n \"prompt\": 123,\n \"completion\": 123,\n \"image\": 123,\n \"audio\": 123,\n \"request\": 123\n },\n \"preferred_min_throughput\": 123,\n \"preferred_max_latency\": 123\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.phaseo.app/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"provider_options\": {},\n \"model\": \"<string>\",\n \"prompts\": [\n \"<string>\"\n ],\n \"items\": [\n {}\n ],\n \"system\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"input_file_id\": \"<string>\",\n \"requests\": [\n {\n \"body\": {},\n \"custom_id\": \"<string>\",\n \"method\": \"POST\",\n \"url\": \"<string>\"\n }\n ],\n \"completion_window\": \"<string>\",\n \"metadata\": {},\n \"session_id\": \"<string>\",\n \"webhook_endpoint_id\": \"<string>\",\n \"debug\": {\n \"enabled\": true,\n \"return_upstream_request\": true,\n \"return_upstream_response\": true,\n \"trace\": true\n },\n \"provider\": {\n \"order\": [\n \"<string>\"\n ],\n \"only\": [\n \"<string>\"\n ],\n \"ignore\": [\n \"<string>\"\n ],\n \"include_alpha\": true,\n \"allow_fallbacks\": true,\n \"require_parameters\": true,\n \"required_execution_region\": \"<string>\",\n \"required_data_region\": \"<string>\",\n \"require_zero_data_retention\": true,\n \"zdr\": true,\n \"enforce_distillable_text\": true,\n \"quantizations\": [\n \"<string>\"\n ],\n \"sort\": \"<string>\",\n \"max_price\": {\n \"prompt\": 123,\n \"completion\": 123,\n \"image\": 123,\n \"audio\": 123,\n \"request\": 123\n },\n \"preferred_min_throughput\": 123,\n \"preferred_max_latency\": 123\n }\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/batches",
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([
'provider_options' => [
],
'model' => '<string>',
'prompts' => [
'<string>'
],
'items' => [
[
]
],
'system' => '<string>',
'max_tokens' => 123,
'temperature' => 123,
'input_file_id' => '<string>',
'requests' => [
[
'body' => [
],
'custom_id' => '<string>',
'method' => 'POST',
'url' => '<string>'
]
],
'completion_window' => '<string>',
'metadata' => [
],
'session_id' => '<string>',
'webhook_endpoint_id' => '<string>',
'debug' => [
'enabled' => true,
'return_upstream_request' => true,
'return_upstream_response' => true,
'trace' => true
],
'provider' => [
'order' => [
'<string>'
],
'only' => [
'<string>'
],
'ignore' => [
'<string>'
],
'include_alpha' => true,
'allow_fallbacks' => true,
'require_parameters' => true,
'required_execution_region' => '<string>',
'required_data_region' => '<string>',
'require_zero_data_retention' => true,
'zdr' => true,
'enforce_distillable_text' => true,
'quantizations' => [
'<string>'
],
'sort' => '<string>',
'max_price' => [
'prompt' => 123,
'completion' => 123,
'image' => 123,
'audio' => 123,
'request' => 123
],
'preferred_min_throughput' => 123,
'preferred_max_latency' => 123
]
]),
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;
}require 'uri'
require 'net/http'
url = URI("https://api.phaseo.app/v1/batches")
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 \"provider_options\": {},\n \"model\": \"<string>\",\n \"prompts\": [\n \"<string>\"\n ],\n \"items\": [\n {}\n ],\n \"system\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"input_file_id\": \"<string>\",\n \"requests\": [\n {\n \"body\": {},\n \"custom_id\": \"<string>\",\n \"method\": \"POST\",\n \"url\": \"<string>\"\n }\n ],\n \"completion_window\": \"<string>\",\n \"metadata\": {},\n \"session_id\": \"<string>\",\n \"webhook_endpoint_id\": \"<string>\",\n \"debug\": {\n \"enabled\": true,\n \"return_upstream_request\": true,\n \"return_upstream_response\": true,\n \"trace\": true\n },\n \"provider\": {\n \"order\": [\n \"<string>\"\n ],\n \"only\": [\n \"<string>\"\n ],\n \"ignore\": [\n \"<string>\"\n ],\n \"include_alpha\": true,\n \"allow_fallbacks\": true,\n \"require_parameters\": true,\n \"required_execution_region\": \"<string>\",\n \"required_data_region\": \"<string>\",\n \"require_zero_data_retention\": true,\n \"zdr\": true,\n \"enforce_distillable_text\": true,\n \"quantizations\": [\n \"<string>\"\n ],\n \"sort\": \"<string>\",\n \"max_price\": {\n \"prompt\": 123,\n \"completion\": 123,\n \"image\": 123,\n \"audio\": 123,\n \"request\": 123\n },\n \"preferred_min_throughput\": 123,\n \"preferred_max_latency\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"native_batch_id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"errors": {},
"input_file_id": "<string>",
"completion_window": "<string>",
"status": "<string>",
"lifecycle_status": "pending",
"progress": 50,
"polling_url": "<string>",
"websocket_url": "<string>",
"cancel_url": "<string>",
"results_url": "<string>",
"output_file_id": "<string>",
"error_file_id": "<string>",
"created_at": 123,
"in_progress_at": 123,
"expires_at": 123,
"finalizing_at": 123,
"completed_at": 123,
"failed_at": 123,
"expired_at": 123,
"cancelling_at": 123,
"cancelled_at": 123,
"request_counts": {
"total": 123,
"completed": 123,
"failed": 123
},
"metadata": {},
"request_id": "<string>",
"provider": "<string>",
"session_id": "<string>",
"webhook": {
"url": "<string>",
"events": [
"<string>"
],
"has_secret": true,
"delivery": {
"total_attempts": 123,
"delivered_events": 123,
"delivered_event_types": [
"video.completed"
],
"pending_retries": 123,
"next_retry_at": "<string>",
"last_attempt_at": "<string>",
"last_attempt_status": "delivered",
"last_response_status": 123,
"last_delivered_at": "<string>",
"last_failure_at": "<string>",
"last_error_message": "<string>"
},
"attempts": [
{
"id": "<string>",
"delivery_key": "video.completed",
"event_type": "video.completed",
"status": "delivered",
"attempt_number": 123,
"max_attempts": 123,
"tried_at": "<string>",
"delivered_at": "<string>",
"next_retry_at": "<string>",
"response_status": 123,
"error_message": "<string>",
"response_body_preview": "<string>"
}
]
},
"next_webhook_retry_at": "<string>",
"last_webhook_progress": 123,
"last_webhook_progress_at": "<string>",
"last_webhook_dispatched_at": "<string>",
"finalized_at": "<string>",
"pricing_lines": [
{}
],
"usage": {
"requests": 123,
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"cost_nanos": 123,
"cost_usd": 123,
"currency": "<string>"
},
"billing": {
"currency": "<string>",
"billed": true,
"charged": true,
"reason": "<string>",
"state": "pending",
"reservation_id": "<string>",
"reservation_status": "<string>",
"estimated_provider_cost": "<string>",
"estimated_user_cost": "<string>",
"settled_provider_cost": "<string>",
"settled_user_cost": "<string>",
"estimated_nanos": 123,
"reserved_nanos": 123,
"estimation_truncated": true,
"estimation_sample_size": 123,
"estimation_total_rows": 123,
"total_nanos": 123,
"cost_nanos": 123,
"cost_usd": 123,
"finalized_at": "<string>",
"pricing_breakdown": {}
}
}{
"error": "error_type",
"ok": false,
"message": "Human-readable error message",
"description": "Additional error details.",
"generation_id": "G-abc123",
"status_code": 502,
"error_type": "system",
"error_origin": "upstream",
"reason": "all_candidates_failed",
"attempt_count": 2,
"failed_providers": [
"google-ai-studio",
"openai"
],
"failed_statuses": [
403,
429
],
"upstream_error": {
"code": "PERMISSION_DENIED",
"message": "The caller does not have permission.",
"description": "<string>",
"param": "<string>"
},
"failure_sample": [
{
"provider": "<string>",
"type": "<string>",
"status": 123,
"upstream_error_code": "<string>",
"upstream_error_message": "<string>",
"upstream_error_description": "<string>",
"upstream_error_param": "<string>",
"upstream_payload_preview": "<string>",
"retryable": true
}
],
"provider_failure_diagnostics": {
"category": "credentials_not_configured",
"hint": "<string>",
"provider": "<string>"
},
"routing_diagnostics": {
"filterStages": [
{
"stage": "<string>",
"beforeCount": 123,
"afterCount": 123,
"droppedProviders": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
}
]
},
"provider_candidate_diagnostics": {
"totalProviders": 123,
"supportsEndpointCount": 123,
"candidateCount": 123,
"droppedUnsupportedEndpoint": [
"<string>"
],
"droppedMissingAdapter": [
{
"providerId": "<string>",
"endpoint": "<string>"
}
]
},
"provider_enablement": {
"capability": "<string>",
"providersBefore": [
"<string>"
],
"providersAfter": [
"<string>"
],
"dropped": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
},
"missing_pricing_providers": [
"<string>"
],
"provider_payment_required_provider": "openai",
"provider_payment_required_support_notice": "Our upstream provider billing appears to be unavailable. If this persists, contact support.",
"details": [
{}
]
}创建批处理
创建异步批处理任务并返回上游批处理对象。通过请求的model支持OpenAI、Anthropic、Google Gemini、Mistral、xAI、Groq和Together AI。网关从模型推断上游提供商,并接受用于可观测性和异步通知的session_id和webhook。provider仅应作为高级路由约束使用。
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
provider_options: {},
model: '<string>',
prompts: ['<string>'],
items: [{}],
system: '<string>',
max_tokens: 123,
temperature: 123,
input_file_id: '<string>',
requests: [
{
body: JSON.stringify({}),
custom_id: '<string>',
method: 'POST',
url: '<string>'
}
],
completion_window: '<string>',
metadata: {},
session_id: '<string>',
webhook_endpoint_id: '<string>',
debug: {
enabled: true,
return_upstream_request: true,
return_upstream_response: true,
trace: true
},
provider: {
order: ['<string>'],
only: ['<string>'],
ignore: ['<string>'],
include_alpha: true,
allow_fallbacks: true,
require_parameters: true,
required_execution_region: '<string>',
required_data_region: '<string>',
require_zero_data_retention: true,
zdr: true,
enforce_distillable_text: true,
quantizations: ['<string>'],
sort: '<string>',
max_price: {prompt: 123, completion: 123, image: 123, audio: 123, request: 123},
preferred_min_throughput: 123,
preferred_max_latency: 123
}
})
};
fetch('https://api.phaseo.app/v1/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.phaseo.app/v1/batches"
payload = {
"provider_options": {},
"model": "<string>",
"prompts": ["<string>"],
"items": [{}],
"system": "<string>",
"max_tokens": 123,
"temperature": 123,
"input_file_id": "<string>",
"requests": [
{
"body": {},
"custom_id": "<string>",
"method": "POST",
"url": "<string>"
}
],
"completion_window": "<string>",
"metadata": {},
"session_id": "<string>",
"webhook_endpoint_id": "<string>",
"debug": {
"enabled": True,
"return_upstream_request": True,
"return_upstream_response": True,
"trace": True
},
"provider": {
"order": ["<string>"],
"only": ["<string>"],
"ignore": ["<string>"],
"include_alpha": True,
"allow_fallbacks": True,
"require_parameters": True,
"required_execution_region": "<string>",
"required_data_region": "<string>",
"require_zero_data_retention": True,
"zdr": True,
"enforce_distillable_text": True,
"quantizations": ["<string>"],
"sort": "<string>",
"max_price": {
"prompt": 123,
"completion": 123,
"image": 123,
"audio": 123,
"request": 123
},
"preferred_min_throughput": 123,
"preferred_max_latency": 123
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.phaseo.app/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"provider_options": {},
"model": "<string>",
"prompts": [
"<string>"
],
"items": [
{}
],
"system": "<string>",
"max_tokens": 123,
"temperature": 123,
"input_file_id": "<string>",
"requests": [
{
"body": {},
"custom_id": "<string>",
"method": "POST",
"url": "<string>"
}
],
"completion_window": "<string>",
"metadata": {},
"session_id": "<string>",
"webhook_endpoint_id": "<string>",
"debug": {
"enabled": true,
"return_upstream_request": true,
"return_upstream_response": true,
"trace": true
},
"provider": {
"order": [
"<string>"
],
"only": [
"<string>"
],
"ignore": [
"<string>"
],
"include_alpha": true,
"allow_fallbacks": true,
"require_parameters": true,
"required_execution_region": "<string>",
"required_data_region": "<string>",
"require_zero_data_retention": true,
"zdr": true,
"enforce_distillable_text": true,
"quantizations": [
"<string>"
],
"sort": "<string>",
"max_price": {
"prompt": 123,
"completion": 123,
"image": 123,
"audio": 123,
"request": 123
},
"preferred_min_throughput": 123,
"preferred_max_latency": 123
}
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phaseo.app/v1/batches"
payload := strings.NewReader("{\n \"provider_options\": {},\n \"model\": \"<string>\",\n \"prompts\": [\n \"<string>\"\n ],\n \"items\": [\n {}\n ],\n \"system\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"input_file_id\": \"<string>\",\n \"requests\": [\n {\n \"body\": {},\n \"custom_id\": \"<string>\",\n \"method\": \"POST\",\n \"url\": \"<string>\"\n }\n ],\n \"completion_window\": \"<string>\",\n \"metadata\": {},\n \"session_id\": \"<string>\",\n \"webhook_endpoint_id\": \"<string>\",\n \"debug\": {\n \"enabled\": true,\n \"return_upstream_request\": true,\n \"return_upstream_response\": true,\n \"trace\": true\n },\n \"provider\": {\n \"order\": [\n \"<string>\"\n ],\n \"only\": [\n \"<string>\"\n ],\n \"ignore\": [\n \"<string>\"\n ],\n \"include_alpha\": true,\n \"allow_fallbacks\": true,\n \"require_parameters\": true,\n \"required_execution_region\": \"<string>\",\n \"required_data_region\": \"<string>\",\n \"require_zero_data_retention\": true,\n \"zdr\": true,\n \"enforce_distillable_text\": true,\n \"quantizations\": [\n \"<string>\"\n ],\n \"sort\": \"<string>\",\n \"max_price\": {\n \"prompt\": 123,\n \"completion\": 123,\n \"image\": 123,\n \"audio\": 123,\n \"request\": 123\n },\n \"preferred_min_throughput\": 123,\n \"preferred_max_latency\": 123\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.phaseo.app/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"provider_options\": {},\n \"model\": \"<string>\",\n \"prompts\": [\n \"<string>\"\n ],\n \"items\": [\n {}\n ],\n \"system\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"input_file_id\": \"<string>\",\n \"requests\": [\n {\n \"body\": {},\n \"custom_id\": \"<string>\",\n \"method\": \"POST\",\n \"url\": \"<string>\"\n }\n ],\n \"completion_window\": \"<string>\",\n \"metadata\": {},\n \"session_id\": \"<string>\",\n \"webhook_endpoint_id\": \"<string>\",\n \"debug\": {\n \"enabled\": true,\n \"return_upstream_request\": true,\n \"return_upstream_response\": true,\n \"trace\": true\n },\n \"provider\": {\n \"order\": [\n \"<string>\"\n ],\n \"only\": [\n \"<string>\"\n ],\n \"ignore\": [\n \"<string>\"\n ],\n \"include_alpha\": true,\n \"allow_fallbacks\": true,\n \"require_parameters\": true,\n \"required_execution_region\": \"<string>\",\n \"required_data_region\": \"<string>\",\n \"require_zero_data_retention\": true,\n \"zdr\": true,\n \"enforce_distillable_text\": true,\n \"quantizations\": [\n \"<string>\"\n ],\n \"sort\": \"<string>\",\n \"max_price\": {\n \"prompt\": 123,\n \"completion\": 123,\n \"image\": 123,\n \"audio\": 123,\n \"request\": 123\n },\n \"preferred_min_throughput\": 123,\n \"preferred_max_latency\": 123\n }\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phaseo.app/v1/batches",
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([
'provider_options' => [
],
'model' => '<string>',
'prompts' => [
'<string>'
],
'items' => [
[
]
],
'system' => '<string>',
'max_tokens' => 123,
'temperature' => 123,
'input_file_id' => '<string>',
'requests' => [
[
'body' => [
],
'custom_id' => '<string>',
'method' => 'POST',
'url' => '<string>'
]
],
'completion_window' => '<string>',
'metadata' => [
],
'session_id' => '<string>',
'webhook_endpoint_id' => '<string>',
'debug' => [
'enabled' => true,
'return_upstream_request' => true,
'return_upstream_response' => true,
'trace' => true
],
'provider' => [
'order' => [
'<string>'
],
'only' => [
'<string>'
],
'ignore' => [
'<string>'
],
'include_alpha' => true,
'allow_fallbacks' => true,
'require_parameters' => true,
'required_execution_region' => '<string>',
'required_data_region' => '<string>',
'require_zero_data_retention' => true,
'zdr' => true,
'enforce_distillable_text' => true,
'quantizations' => [
'<string>'
],
'sort' => '<string>',
'max_price' => [
'prompt' => 123,
'completion' => 123,
'image' => 123,
'audio' => 123,
'request' => 123
],
'preferred_min_throughput' => 123,
'preferred_max_latency' => 123
]
]),
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;
}require 'uri'
require 'net/http'
url = URI("https://api.phaseo.app/v1/batches")
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 \"provider_options\": {},\n \"model\": \"<string>\",\n \"prompts\": [\n \"<string>\"\n ],\n \"items\": [\n {}\n ],\n \"system\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"input_file_id\": \"<string>\",\n \"requests\": [\n {\n \"body\": {},\n \"custom_id\": \"<string>\",\n \"method\": \"POST\",\n \"url\": \"<string>\"\n }\n ],\n \"completion_window\": \"<string>\",\n \"metadata\": {},\n \"session_id\": \"<string>\",\n \"webhook_endpoint_id\": \"<string>\",\n \"debug\": {\n \"enabled\": true,\n \"return_upstream_request\": true,\n \"return_upstream_response\": true,\n \"trace\": true\n },\n \"provider\": {\n \"order\": [\n \"<string>\"\n ],\n \"only\": [\n \"<string>\"\n ],\n \"ignore\": [\n \"<string>\"\n ],\n \"include_alpha\": true,\n \"allow_fallbacks\": true,\n \"require_parameters\": true,\n \"required_execution_region\": \"<string>\",\n \"required_data_region\": \"<string>\",\n \"require_zero_data_retention\": true,\n \"zdr\": true,\n \"enforce_distillable_text\": true,\n \"quantizations\": [\n \"<string>\"\n ],\n \"sort\": \"<string>\",\n \"max_price\": {\n \"prompt\": 123,\n \"completion\": 123,\n \"image\": 123,\n \"audio\": 123,\n \"request\": 123\n },\n \"preferred_min_throughput\": 123,\n \"preferred_max_latency\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"native_batch_id": "<string>",
"object": "<string>",
"endpoint": "<string>",
"errors": {},
"input_file_id": "<string>",
"completion_window": "<string>",
"status": "<string>",
"lifecycle_status": "pending",
"progress": 50,
"polling_url": "<string>",
"websocket_url": "<string>",
"cancel_url": "<string>",
"results_url": "<string>",
"output_file_id": "<string>",
"error_file_id": "<string>",
"created_at": 123,
"in_progress_at": 123,
"expires_at": 123,
"finalizing_at": 123,
"completed_at": 123,
"failed_at": 123,
"expired_at": 123,
"cancelling_at": 123,
"cancelled_at": 123,
"request_counts": {
"total": 123,
"completed": 123,
"failed": 123
},
"metadata": {},
"request_id": "<string>",
"provider": "<string>",
"session_id": "<string>",
"webhook": {
"url": "<string>",
"events": [
"<string>"
],
"has_secret": true,
"delivery": {
"total_attempts": 123,
"delivered_events": 123,
"delivered_event_types": [
"video.completed"
],
"pending_retries": 123,
"next_retry_at": "<string>",
"last_attempt_at": "<string>",
"last_attempt_status": "delivered",
"last_response_status": 123,
"last_delivered_at": "<string>",
"last_failure_at": "<string>",
"last_error_message": "<string>"
},
"attempts": [
{
"id": "<string>",
"delivery_key": "video.completed",
"event_type": "video.completed",
"status": "delivered",
"attempt_number": 123,
"max_attempts": 123,
"tried_at": "<string>",
"delivered_at": "<string>",
"next_retry_at": "<string>",
"response_status": 123,
"error_message": "<string>",
"response_body_preview": "<string>"
}
]
},
"next_webhook_retry_at": "<string>",
"last_webhook_progress": 123,
"last_webhook_progress_at": "<string>",
"last_webhook_dispatched_at": "<string>",
"finalized_at": "<string>",
"pricing_lines": [
{}
],
"usage": {
"requests": 123,
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"cost_nanos": 123,
"cost_usd": 123,
"currency": "<string>"
},
"billing": {
"currency": "<string>",
"billed": true,
"charged": true,
"reason": "<string>",
"state": "pending",
"reservation_id": "<string>",
"reservation_status": "<string>",
"estimated_provider_cost": "<string>",
"estimated_user_cost": "<string>",
"settled_provider_cost": "<string>",
"settled_user_cost": "<string>",
"estimated_nanos": 123,
"reserved_nanos": 123,
"estimation_truncated": true,
"estimation_sample_size": 123,
"estimation_total_rows": 123,
"total_nanos": 123,
"cost_nanos": 123,
"cost_usd": 123,
"finalized_at": "<string>",
"pricing_breakdown": {}
}
}{
"error": "error_type",
"ok": false,
"message": "Human-readable error message",
"description": "Additional error details.",
"generation_id": "G-abc123",
"status_code": 502,
"error_type": "system",
"error_origin": "upstream",
"reason": "all_candidates_failed",
"attempt_count": 2,
"failed_providers": [
"google-ai-studio",
"openai"
],
"failed_statuses": [
403,
429
],
"upstream_error": {
"code": "PERMISSION_DENIED",
"message": "The caller does not have permission.",
"description": "<string>",
"param": "<string>"
},
"failure_sample": [
{
"provider": "<string>",
"type": "<string>",
"status": 123,
"upstream_error_code": "<string>",
"upstream_error_message": "<string>",
"upstream_error_description": "<string>",
"upstream_error_param": "<string>",
"upstream_payload_preview": "<string>",
"retryable": true
}
],
"provider_failure_diagnostics": {
"category": "credentials_not_configured",
"hint": "<string>",
"provider": "<string>"
},
"routing_diagnostics": {
"filterStages": [
{
"stage": "<string>",
"beforeCount": 123,
"afterCount": 123,
"droppedProviders": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
}
]
},
"provider_candidate_diagnostics": {
"totalProviders": 123,
"supportsEndpointCount": 123,
"candidateCount": 123,
"droppedUnsupportedEndpoint": [
"<string>"
],
"droppedMissingAdapter": [
{
"providerId": "<string>",
"endpoint": "<string>"
}
]
},
"provider_enablement": {
"capability": "<string>",
"providersBefore": [
"<string>"
],
"providersAfter": [
"<string>"
],
"dropped": [
{
"providerId": "<string>",
"reason": "<string>"
}
]
},
"missing_pricing_providers": [
"<string>"
],
"provider_payment_required_provider": "openai",
"provider_payment_required_support_notice": "Our upstream provider billing appears to be unavailable. If this persists, contact support.",
"details": [
{}
]
}授权
Bearer 令牌身份验证
请求体
按规范提供商ID限定的扩展。OpenAI接受output_expires_after;Mistral接受metadata。仅应用所选提供商的选项。不要在顶层重复同一选项。选项不能覆盖已定价的行、模型或文件。
Show child attributes
Show child attributes
用于推断上游批处理提供商的模型ID。请求行也可包含body.model;优先使用顶层模型。
简单提示词简写。Phaseo将每个提示词编译成适用于所选模型的提供商原生批处理行。
结构化提示词简写。条目可包含id、custom_id、prompt、messages、input、system、max_tokens、temperature或高级body。
应用于提示词简写行的可选系统指令。
应用于提示词简写行的可选最大令牌限制。
应用于提示词简写行的可选采样温度。
通过文件上传创建批处理时使用的现有提供商文件ID。
高级批处理请求行。必须恰好提供prompts、items、requests或input_file_id其中一个。
Show child attributes
Show child attributes
面向调用方的请求格式。批处理中每个请求均使用此端点。省略时,Phaseo根据模型选择提供商原生默认值。
/v1/chat/completions, /v1/responses, /v1/messages, /v1/embeddings, /v1/generateContent 用于可观测性统计的唯一标识符,可将相关请求(例如对话或代理工作流)归为一组。
256Show child attributes
Show child attributes
webhook.endpoint_id的便捷别名。
网关调试控制项。这些标志绝不会转发给提供商。
Show child attributes
Show child attributes
高级路由约束。大多数请求应依赖基于模型的提供商推断。
Show child attributes
Show child attributes
响应
批处理状态响应
与网关自有ID不同时的提供商原生批处理ID。
供轮询、WebSocket和Webhook使用方使用的标准化异步生命周期状态。
pending, running, completed, failed, cancelled, expired 基于提供商请求计数计算的粗略批处理完成百分比(如可用)。已完成批处理报告100。
0 <= x <= 100用于订阅标准化异步任务生命周期更新的WebSocket URL。
为兼容性保留;目前始终为null。
受支持终态批处理的需认证Phaseo JSONL下载URL。处理中为null。终态批处理可能没有输出。请使用所属工作区的API密钥;提供商保留期限限制仍然适用。
Show child attributes
Show child attributes
已清理的异步Webhook配置及投递状态。绝不返回密钥;has_secret表示是否启用签名投递。签名投递包含x-phaseo-signature、x-phaseo-timestamp、x-phaseo-event-id、x-phaseo-event-type、x-phaseo-delivery-key、x-phaseo-attempt和x-phaseo-max-attempts请求头。
Show child attributes
Show child attributes
完成后的标准化汇总使用量和成本。
Show child attributes
Show child attributes
Show child attributes
Show child attributes