| Giá Comet (USD / M Tokens) | Giá Chính Thức (USD / M Tokens) | Giảm giá |
|---|---|---|
Đầu vào:$1.6/M Đầu ra:$3.2/M | Đầu vào:$2/M Đầu ra:$4/M | -20% |
import os
from openai import OpenAI
# Get your CometAPI key from https://www.cometapi.com/console/token, and paste it here
COMETAPI_KEY = os.environ.get("COMETAPI_KEY") or "<YOUR_COMETAPI_KEY>"
BASE_URL = "https://api.cometapi.com/v1"
client = OpenAI(base_url=BASE_URL, api_key=COMETAPI_KEY)
response = client.responses.create(
model="grok-4.5",
input=[
{
"role": "user",
"content": "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}",
}
],
)
print(response.output_text or response.model_dump_json(indent=2))import os
from openai import OpenAI
# Get your CometAPI key from https://www.cometapi.com/console/token, and paste it here
COMETAPI_KEY = os.environ.get("COMETAPI_KEY") or "<YOUR_COMETAPI_KEY>"
BASE_URL = "https://api.cometapi.com/v1"
client = OpenAI(base_url=BASE_URL, api_key=COMETAPI_KEY)
response = client.responses.create(
model="grok-4.5",
input=[
{
"role": "user",
"content": "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}",
}
],
)
print(response.output_text or response.model_dump_json(indent=2))
import OpenAI from "openai";
// Get your CometAPI key from https://www.cometapi.com/console/token, and paste it here
const apiKey = process.env.COMETAPI_KEY || "<YOUR_COMETAPI_KEY>";
const baseUrl = "https://api.cometapi.com/v1";
const client = new OpenAI({
apiKey,
baseURL: baseUrl,
});
const response = await client.responses.create({
model: "grok-4.5",
input: [
{
role: "user",
content: "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}",
},
],
});
console.log(response.output_text ?? JSON.stringify(response.output, null, 2));
#!/usr/bin/env bash
# Get your CometAPI key from https://www.cometapi.com/console/token
# Export it as: export COMETAPI_KEY="your-key-here"
response=$(curl --silent --location --request POST "https://api.cometapi.com/v1/responses" \
--header "Authorization: Bearer $COMETAPI_KEY" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data-raw '{
"model": "grok-4.5",
"input": [
{
"role": "user",
"content": "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"
}
]
}')
if command -v jq >/dev/null 2>&1; then
printf '%s\n' "$response" | jq -r '(
[
.output[]?
| select(.type == "message")
| .content[]?
| select(.type == "output_text")
| .text
][0]
) // .output_text // .'
else
printf '%s\n' "$response"
fi
| version |
|---|
| grok-4.5 |