Skip to main content
POST
/
v1
/
chat
/
completions
qwen-turbo (Text To Text)
curl --request POST \
  --url https://gptproto.com/v1/chat/completions

Authentication

  1. Sign up for a GPTProto account at https://gptproto.com
  2. Navigate to the API Keys section in your dashboard
  3. Generate a new API key (sk-xxxxx)
  4. Copy and securely store your API key For authentication details, please refer to the Authentication section.

Initiate Request

curl --location 'https://gptproto.com/v1/chat/completions' \
--header 'Authorization: GPTPROTO_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "model": "qwen-turbo",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "who are you?"
        }
      ]
    }
  ]
}'

Parameters

Core Parameters

ParameterTypeRequiredDefaultRangeDescription
modelstring✅ Yes--Model ID used to generate the response, like qwen-3.5. Alibaba offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.
messagesarray✅ Yes--A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.
>messages.rolestring✅ Yes-developer
user
system
The role of the messages author.
>messages.namestring❌ No--An optional name for the participant. Provides the model information to differentiate between participants of the same role.
>messages.contentstring / array✅ Yes--The contents of the developer message.
>>messages.content.typestring✅ Yes-text
image_url
The type of the content part
>>messages.content.textstring❌ No--The text content

Advanced Parameters

ParameterTypeRequiredDefaultRangeDescription
max_tokensinteger / null❌ No--The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length.
ninteger / null❌ No11 - 10How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices.
response_formatobject❌ No--An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.
>response_format.typestring✅ Yestexttext
json_object
The type of response format. text for standard text output, json_object for JSON mode.
toolsarray❌ No--A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.
>tools.typestring✅ Yes-functionThe type of the tool. Currently, only function is supported.
>tools.functionobject✅ Yes--The function definition.
>>tools.function.namestring✅ Yes--The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
>>tools.function.descriptionstring❌ No--A description of what the function does, used by the model to choose when and how to call the function.
>>tools.function.parametersobject❌ No--The parameters the functions accepts, described as a JSON Schema object.
streamboolean❌ Nofalsetrue
false
Whether to stream the response back incrementally. Defaults to false.

Response Example

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "{{model}}",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image shows a wooden boardwalk path extending through a lush green grassland."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1250,
    "completion_tokens": 89,
    "total_tokens": 1339
  }
}

Error Codes

Common Error Codes

Error CodeError NameDescription
401UnauthorizedAPI key is missing or invalid
403ForbiddenYour API key doesn’t have permission to access this resource, or insufficient balance for the requested operation
429Too Many RequestsYou’ve exceeded your rate limit
500Internal server errorAn internal server error occurred
503Content policy violationContent blocked due to safety concerns (actual status code is 400)