{"id":"ai.rerank","module":"ai-runtime","namespace":"ai","action":"rerank","method":"POST","path":"/v1/ai/rerank","idempotent":false,"available":true,"vendors":["cohere","jina","qwen","alibaba_intl"],"vendors_ready":["alibaba_intl"],"vendors_pending":["cohere","jina","qwen"],"key_status":"live","default_vendor":"alibaba_intl","self_hosted":false,"minimum_tier":"standard","supported_message_classes":null,"regions":["western","china"],"dynamic_params":{"vendor":["alibaba_intl"]},"models_tracked":false,"sdk_hint":"Regular parameters + types are stable — read them from the typed SDK signature / API reference for this capability. discovery only carries the runtime-dynamic values above (available, vendors, dynamic_params).","params":{"title":"RerankRequest","description":"Request payload for ai.rerank — order candidate documents by relevance to a query.","type":"object","required":["query","candidates"],"additionalProperties":false,"properties":{"query":{"type":"string","minLength":1,"description":"Search query string for reranking"},"candidates":{"type":"array","minItems":1,"items":{"type":"string"},"description":"Documents to score against the query; the response returns them reordered by relevance."},"top_k":{"type":"integer","minimum":1,"default":10,"description":"Number of top results to return"},"model":{"type":"string","description":"Optional model pin (e.g. rerank-english-v3.0, gte-rerank)."},"vendor":{"enum":["cohere","jina","qwen","alibaba_intl"],"description":"Optional vendor pin."}}},"response":{"title":"RerankResult","description":"Result payload for ai.rerank. Ranked indices + relevance scores are exactly what the vendor produced (no synthetic ordering).","type":"object","required":["ranked"],"additionalProperties":false,"properties":{"ranked":{"type":"array","items":{"type":"object","required":["index","score"],"additionalProperties":false,"properties":{"index":{"type":"integer","minimum":0,"description":"Index into the original candidates list."},"score":{"type":"number","description":"Vendor relevance score (higher = more relevant)."}}},"description":"Ranked list of candidates after reranking"}}},"errors":["ACCOUNT_AUTORECHARGE_LIMIT","ACCOUNT_FROZEN","AUTH_RATE_LIMIT","AUTH_REFRESH_TOO_FREQUENT","BATCH_REJECTED","CAPABILITY_DEGRADED_NOT_ALLOWED","CONTENT_FILTERED","CONTEXT_WINDOW_EXCEEDED","FAILOVER_COST_EXCEEDED","IDEMPOTENCY_KEY_CONFLICT","INSUFFICIENT_CREDIT","INTERNAL_ERROR","INVALID_ARGUMENT","INVALID_MESSAGE_SCHEMA","INVALID_RESPONSE_FORMAT","INVALID_TOOL_SCHEMA","KEY_REVOKED","MAINTENANCE","MODEL_DEPRECATED","MODEL_NOT_AVAILABLE","MODEL_NOT_FOUND","MODEL_NO_IMAGE_INPUT","MODEL_QUOTA_EXCEEDED","NETWORK_ERROR","NO_HEALTHY_KEY","NO_HEALTHY_VENDOR","RATE_LIMIT_ACCOUNT","RATE_LIMIT_USER","RATE_LIMIT_VENDOR","SCOPE_INSUFFICIENT","STREAM_INTERRUPTED","UNAUTHORIZED","VENDOR_AUTH_ERROR","VENDOR_DOWN","VENDOR_KEY_DUPLICATE","VENDOR_KEY_INVALID","VENDOR_KEY_NOT_FOUND","VENDOR_NOT_CONFIGURED","VENDOR_REQUEST_FAILED","VENDOR_REQUEST_INVALID","VENDOR_RESPONSE_INVALID","VENDOR_TIMEOUT","WALLET_EXPIRED"],"examples":{"curl":"curl -X POST https://api.infrai.cc/v1/ai/rerank \\\n  -H \"Authorization: Bearer $INFRAI_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"query\": \"hello\", \"candidates\": [\"sample\"]}'","python":"# Zero-install REST call — no SDK required (short-term the API is REST-only).\nimport os, requests\n\nresp = requests.post(\n    \"https://api.infrai.cc/v1/ai/rerank\",\n    headers={\n        \"Authorization\": f\"Bearer {os.environ['INFRAI_API_KEY']}\",\n    },\n    json={'query': 'hello', 'candidates': ['sample']},\n)\nresp.raise_for_status()\nprint(resp.json())","javascript":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nconst resp = await fetch(\n  \"https://api.infrai.cc/v1/ai/rerank\",\n  {\n    method: \"POST\",\n    headers: {\n      \"Authorization\": `Bearer ${process.env.INFRAI_API_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\"query\": \"hello\", \"candidates\": [\"sample\"]}),\n  },\n);\nconsole.log(await resp.json());","typescript":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nconst resp = await fetch(\n  \"https://api.infrai.cc/v1/ai/rerank\",\n  {\n    method: \"POST\",\n    headers: {\n      \"Authorization\": `Bearer ${process.env.INFRAI_API_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\"query\": \"hello\", \"candidates\": [\"sample\"]}),\n  },\n);\nif (!resp.ok) throw new Error(`infrai ${resp.status}`);\nconst data: unknown = await resp.json();\nconsole.log(data);","go":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\tbody := []byte(`{\"query\": \"hello\", \"candidates\": [\"sample\"]}`)\n\treq, _ := http.NewRequest(\"POST\", \"https://api.infrai.cc/v1/ai/rerank\", bytes.NewReader(body))\n\treq.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"INFRAI_API_KEY\"))\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\tfmt.Println(resp.Status)\n}","java":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nimport java.net.URI;\nimport java.net.http.*;\n\nHttpRequest req = HttpRequest.newBuilder()\n    .uri(URI.create(\"https://api.infrai.cc/v1/ai/rerank\"))\n    .header(\"Authorization\", \"Bearer \" + System.getenv(\"INFRAI_API_KEY\"))\n    .header(\"Content-Type\", \"application/json\")\n    .method(\"POST\", HttpRequest.BodyPublishers.ofString(\"{\\\"query\\\": \\\"hello\\\", \\\"candidates\\\": [\\\"sample\\\"]}\"))\n    .build();\nHttpResponse<String> resp = HttpClient.newHttpClient()\n    .send(req, HttpResponse.BodyHandlers.ofString());\nSystem.out.println(resp.body());","csharp":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nusing System;\nusing System.Net.Http;\n\nvar client = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://api.infrai.cc/v1/ai/rerank\");\nvar key = Environment.GetEnvironmentVariable(\"INFRAI_API_KEY\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + key);\nreq.Content = new StringContent(\"{\\\"query\\\": \\\"hello\\\", \\\"candidates\\\": [\\\"sample\\\"]}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await client.SendAsync(req);\nConsole.WriteLine(await resp.Content.ReadAsStringAsync());","php":"<?php\n// Zero-install REST call — no SDK required (short-term the API is REST-only).\n$ch = curl_init(\"https://api.infrai.cc/v1/ai/rerank\");\ncurl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"POST\");\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, [\n    \"Authorization: Bearer \" . getenv(\"INFRAI_API_KEY\"),\n    \"Content-Type: application/json\",\n]);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, \"{\\\"query\\\": \\\"hello\\\", \\\"candidates\\\": [\\\"sample\\\"]}\");\n$response = curl_exec($ch);\ncurl_close($ch);\necho $response;","ruby":"# Zero-install REST call — no SDK required (short-term the API is REST-only).\nrequire \"net/http\"\nrequire \"uri\"\n\nuri = URI(\"https://api.infrai.cc/v1/ai/rerank\")\nhttp = Net::HTTP.new(uri.host, uri.port)\nhttp.use_ssl = true\nreq = Net::HTTP::Post.new(uri)\nreq[\"Authorization\"] = \"Bearer #{ENV['INFRAI_API_KEY']}\"\nreq[\"Content-Type\"] = \"application/json\"\nreq.body = '{\"query\": \"hello\", \"candidates\": [\"sample\"]}'\nres = http.request(req)\nputs res.body","rust":"// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)\nuse std::env;\n\n#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n    let resp = reqwest::Client::new()\n        .post(\"https://api.infrai.cc/v1/ai/rerank\")\n        .header(\"Authorization\", format!(\"Bearer {}\", env::var(\"INFRAI_API_KEY\")?))\n        .header(\"Content-Type\", \"application/json\")\n        .body(r#\"{\"query\": \"hello\", \"candidates\": [\"sample\"]}\"#)\n        .send()\n        .await?;\n    println!(\"{}\", resp.text().await?);\n    Ok(())\n}","request":{"query":"hello","candidates":["sample"]}},"billing":{"is_billable":true,"free":false,"billing_class":"ai_region_markup","unit":"per_request","price_usd":0.00105,"currency":"USD","approximate":true,"new_account_trial_uses":1904,"note":"new accounts get $2 free → ~1904 free requests (estimate; depends on token usage)"}}