Exemplos
Ainda não existe SDK oficial. Use HTTP diretamente a partir do servidor da sua aplicação.
cURL
curl https://api.tipochat.co.mz/v1/responses \
-X POST \
-H "Authorization: Bearer $TIPOCHAT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "tipo-text",
"input": "Escreve uma saudação curta.",
"max_output_tokens": 120
}'JavaScript
const response = await fetch("https://api.tipochat.co.mz/v1/responses", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TIPOCHAT_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
model: "tipo-text",
input: "Resume este texto: …",
max_output_tokens: 180,
}),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error?.code || "tipochat_error");
console.log(body.output_text);PHP
<?php
$curl = curl_init("https://api.tipochat.co.mz/v1/responses");
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode([
"model" => "tipo-text",
"input" => "Escreve uma saudação curta."
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("TIPOCHAT_API_KEY"),
"Content-Type: application/json",
"Idempotency-Key: " . bin2hex(random_bytes(16))
]
]);
$body = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);