Create completions — POST /v1/completions

Implements the OpenAI-compatible chat completions API

POST /v1/completions

Addresshttps://api.hanzo.ai/v1/completions
MethodPOST
Operationpost_completions
AuthAuthorization: Bearer $HANZO_API_KEY

Implements the OpenAI-compatible chat completions API

Request

69 fields, body application/json (required).

FieldInTypeRequiredDescription
X-Max-Costheadernumber—The most this request may cost, in USD per 1,000 tokens.
X-Max-Latency-Msheaderinteger—The slowest model this request accepts, in milliseconds.
frequency_penaltybodynumber—
function_callbodyany—
functionsbodyopenai.FunctionDefinition[]—
functions[].descriptionbodystring—
functions[].namebodystring—
functions[].parametersbodyany—
functions[].strictbodyboolean—
logit_biasbodyobject—
logit_bias.*bodyinteger—
logprobsbodyboolean—
max_completion_tokensbodyinteger—
max_tokensbodyinteger—
messagesbodyopenai.ChatCompletionMessage[]—
messages[].MultiContentbodyopenai.ChatMessagePart[]—
messages[].MultiContent[].image_urlbodyopenai.ChatMessageImageURL—
messages[].MultiContent[].image_url.detailbodystring—
messages[].MultiContent[].image_url.urlbodystring—
messages[].MultiContent[].textbodystring—
messages[].MultiContent[].typebodystring—
messages[].contentbodystring—
messages[].function_callbodyopenai.FunctionCall—
messages[].function_call.argumentsbodystring—
messages[].function_call.namebodystring—
messages[].namebodystring—
messages[].reasoning_contentbodystring—
messages[].refusalbodystring—
messages[].rolebodystring—
messages[].tool_call_idbodystring—
messages[].tool_callsbodyopenai.ToolCall[]—
messages[].tool_calls[].functionbodyopenai.FunctionCall—
messages[].tool_calls[].function.argumentsbodystring—
messages[].tool_calls[].function.namebodystring—
messages[].tool_calls[].idbodystring—
messages[].tool_calls[].indexbodyinteger—
messages[].tool_calls[].typebodystring—
metadatabodyobject—
metadata.*bodystring—
modelbodystring—
nbodyinteger—
parallel_tool_callsbodyany—
presence_penaltybodynumber—
reasoning_effortbodystring—
response_formatbodyopenai.ChatCompletionResponseFormat—
response_format.json_schemabodyopenai.ChatCompletionResponseFormatJSONSchema—
response_format.json_schema.descriptionbodystring—
response_format.json_schema.namebodystring—
response_format.json_schema.schemabodyany—
response_format.json_schema.strictbodyboolean—
response_format.typebodystring—
seedbodyinteger—
stopbodystring[]—
storebodyboolean—
streambodyboolean—
stream_optionsbodyopenai.StreamOptions—
stream_options.include_usagebodyboolean—
temperaturebodynumber—
tool_choicebodyany—
toolsbodyopenai.Tool[]—
tools[].functionbodyopenai.FunctionDefinition—
tools[].function.descriptionbodystring—
tools[].function.namebodystring—
tools[].function.parametersbodyany—
tools[].function.strictbodyboolean—
tools[].typebodystring—
top_logprobsbodyinteger—
top_pbodynumber—
userbodystring—

Response

StatusBodyMeaning
200openai.ChatCompletionResponseSuccess.
401—No credential, or one this service does not accept.
403—A valid credential that may not do this.

200 body — 90 fields.

FieldInTypeAlwaysDescription
choicesbodyopenai.ChatCompletionChoice[]—
choices[].content_filter_resultsbodyopenai.ContentFilterResults—
choices[].content_filter_results.hatebodyopenai.Hate—
choices[].content_filter_results.hate.filteredbodyboolean—
choices[].content_filter_results.hate.severitybodystring—
choices[].content_filter_results.jailbreakbodyopenai.JailBreak—
choices[].content_filter_results.jailbreak.detectedbodyboolean—
choices[].content_filter_results.jailbreak.filteredbodyboolean—
choices[].content_filter_results.profanitybodyopenai.Profanity—
choices[].content_filter_results.profanity.detectedbodyboolean—
choices[].content_filter_results.profanity.filteredbodyboolean—
choices[].content_filter_results.self_harmbodyopenai.SelfHarm—
choices[].content_filter_results.self_harm.filteredbodyboolean—
choices[].content_filter_results.self_harm.severitybodystring—
choices[].content_filter_results.sexualbodyopenai.Sexual—
choices[].content_filter_results.sexual.filteredbodyboolean—
choices[].content_filter_results.sexual.severitybodystring—
choices[].content_filter_results.violencebodyopenai.Violence—
choices[].content_filter_results.violence.filteredbodyboolean—
choices[].content_filter_results.violence.severitybodystring—
choices[].finish_reasonbodystring—
choices[].indexbodyinteger—
choices[].logprobsbodyopenai.LogProbs—
choices[].logprobs.contentbodyopenai.LogProb[]—
choices[].logprobs.content[].bytesbodystring (byte)—
choices[].logprobs.content[].logprobbodynumber—
choices[].logprobs.content[].tokenbodystring—
choices[].logprobs.content[].top_logprobsbodyopenai.TopLogProbs[]—
choices[].logprobs.content[].top_logprobs[].bytesbodystring (byte)—
choices[].logprobs.content[].top_logprobs[].logprobbodynumber—
choices[].logprobs.content[].top_logprobs[].tokenbodystring—
choices[].messagebodyopenai.ChatCompletionMessage—
choices[].message.MultiContentbodyopenai.ChatMessagePart[]—
choices[].message.MultiContent[].image_urlbodyopenai.ChatMessageImageURL—
choices[].message.MultiContent[].image_url.detailbodystring—
choices[].message.MultiContent[].image_url.urlbodystring—
choices[].message.MultiContent[].textbodystring—
choices[].message.MultiContent[].typebodystring—
choices[].message.contentbodystring—
choices[].message.function_callbodyopenai.FunctionCall—
choices[].message.function_call.argumentsbodystring—
choices[].message.function_call.namebodystring—
choices[].message.namebodystring—
choices[].message.reasoning_contentbodystring—
choices[].message.refusalbodystring—
choices[].message.rolebodystring—
choices[].message.tool_call_idbodystring—
choices[].message.tool_callsbodyopenai.ToolCall[]—
choices[].message.tool_calls[].functionbodyopenai.FunctionCall—
choices[].message.tool_calls[].function.argumentsbodystring—
choices[].message.tool_calls[].function.namebodystring—
choices[].message.tool_calls[].idbodystring—
choices[].message.tool_calls[].indexbodyinteger—
choices[].message.tool_calls[].typebodystring—
createdbodyinteger—
idbodystring—
modelbodystring—
objectbodystring—
prompt_filter_resultsbodyopenai.PromptFilterResult[]—
prompt_filter_results[].content_filter_resultsbodyopenai.ContentFilterResults—
prompt_filter_results[].content_filter_results.hatebodyopenai.Hate—
prompt_filter_results[].content_filter_results.hate.filteredbodyboolean—
prompt_filter_results[].content_filter_results.hate.severitybodystring—
prompt_filter_results[].content_filter_results.jailbreakbodyopenai.JailBreak—
prompt_filter_results[].content_filter_results.jailbreak.detectedbodyboolean—
prompt_filter_results[].content_filter_results.jailbreak.filteredbodyboolean—
prompt_filter_results[].content_filter_results.profanitybodyopenai.Profanity—
prompt_filter_results[].content_filter_results.profanity.detectedbodyboolean—
prompt_filter_results[].content_filter_results.profanity.filteredbodyboolean—
prompt_filter_results[].content_filter_results.self_harmbodyopenai.SelfHarm—
prompt_filter_results[].content_filter_results.self_harm.filteredbodyboolean—
prompt_filter_results[].content_filter_results.self_harm.severitybodystring—
prompt_filter_results[].content_filter_results.sexualbodyopenai.Sexual—
prompt_filter_results[].content_filter_results.sexual.filteredbodyboolean—
prompt_filter_results[].content_filter_results.sexual.severitybodystring—
prompt_filter_results[].content_filter_results.violencebodyopenai.Violence—
prompt_filter_results[].content_filter_results.violence.filteredbodyboolean—
prompt_filter_results[].content_filter_results.violence.severitybodystring—
prompt_filter_results[].indexbodyinteger—
system_fingerprintbodystring—
usagebodyopenai.Usage—
usage.completion_tokensbodyinteger—
usage.completion_tokens_detailsbodyopenai.CompletionTokensDetails—
usage.completion_tokens_details.audio_tokensbodyinteger—
usage.completion_tokens_details.reasoning_tokensbodyinteger—
usage.prompt_tokensbodyinteger—
usage.prompt_tokens_detailsbodyopenai.PromptTokensDetails—
usage.prompt_tokens_details.audio_tokensbodyinteger—
usage.prompt_tokens_details.cached_tokensbodyinteger—
usage.total_tokensbodyinteger—

Failure carries the platform error shape — see Errors.

Examples

hanzo completions create
import { Configuration, AiApi } from 'hanzoai';

const api = new AiApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postCompletions({ frequency_penalty: 0, function_call: "<function_call>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AiApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AiApi(client).post_completions(frequency_penalty=0, function_call="<function_call>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AiAPI.PostCompletions(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, ai_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = ai_api::post_completions(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AiApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AiApi(client).postCompletions();
curl -X POST https://api.hanzo.ai/v1/completions \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "frequency_penalty": 0,
       "function_call": "<function_call>"
     }'

MCP declares no tool for ai — tools/list on https://api.hanzo.ai/v1/mcp names the products it does reach. Use HTTP or an SDK.


AI API · All Hanzo APIs · Interactive reference

Was this page useful?