Skip to content

Qwen3 ASR Speech Recognition

qwen3-asr-flash converts audio to text through the OpenAI-compatible Chat Completions API. Put the audio in messages[].content[].

Endpoint

http
POST /v1/chat/completions

Full URL:

text
https://cubicspaces.cloud/v1/chat/completions

Supported Model

ModelDescription
qwen3-asr-flashSpeech recognition for short audio

Actual availability depends on your account permissions and platform configuration.

Quick Start

You can provide a publicly accessible audio URL:

bash
curl https://cubicspaces.cloud/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-asr-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_audio",
            "input_audio": {
              "data": "https://example.com/audio.mp3"
            }
          }
        ]
      }
    ],
    "asr_options": {
      "language": "en",
      "enable_itn": true
    },
    "stream": false
  }'

Request Fields

FieldTypeRequiredDescription
modelstringYesMust be qwen3-asr-flash
messagesarrayYesOpenAI Chat message array
messages[].rolestringYesUse user for the audio message
messages[].contentarrayYesMultimodal content array
content[].typestringYesMust be input_audio
content[].input_audio.datastringYesPublic audio URL or Base64 Data URI
asr_options.languagestringNoLanguage code when the audio language is known
asr_options.enable_itnbooleanNoConverts spoken numbers to digits; default is false
streambooleanNoEnables SSE streaming; default is false
stream_options.include_usagebooleanNoReturns usage at the end of a streaming response

asr_options belongs at the top level of the request body. Do not place it inside messages or input_audio.

Common language codes include:

  • zh: Chinese (Mandarin, Sichuanese, Minnan, and Wu)
  • yue: Cantonese
  • en: English
  • ja: Japanese
  • de, ko, ru, fr, pt, ar, it, es
  • hi, id, th, tr, uk, vi, cs, da, fil, fi, is, ms, no, pl, sv

Omit language when the audio is multilingual or the language is unknown.

Base64 Audio

Convert a local file to a Data URI:

python
import base64
from pathlib import Path

audio = Path("audio.mp3").read_bytes()
audio_data = "data:audio/mpeg;base64," + base64.b64encode(audio).decode()

Then pass audio_data as input_audio.data.

Response Example

Read the transcript from choices[0].message.content:

json
{
  "id": "chatcmpl_123",
  "object": "chat.completion",
  "model": "qwen3-asr-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Welcome to Cubicspaces."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 45,
    "completion_tokens": 12,
    "total_tokens": 57,
    "seconds": 1
  }
}
Response FieldDescription
choices[0].message.contentRecognized text
usage.prompt_tokensInput usage
usage.completion_tokensOutput text usage
usage.total_tokensTotal token usage
usage.secondsInput audio duration in seconds

SDK Examples

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://cubicspaces.cloud/v1"
)

response = client.chat.completions.create(
    model="qwen3-asr-flash",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://example.com/audio.mp3"
                    }
                }
            ]
        }
    ],
    extra_body={
        "asr_options": {
            "language": "en",
            "enable_itn": True
        }
    }
)

print(response.choices[0].message.content)
print(response.usage)
js
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://cubicspaces.cloud/v1"
});

const response = await client.chat.completions.create({
  model: "qwen3-asr-flash",
  messages: [
    {
      role: "user",
      content: [
        {
          type: "input_audio",
          input_audio: {
            data: "https://example.com/audio.mp3"
          }
        }
      ]
    }
  ],
  asr_options: {
    language: "en",
    enable_itn: true
  }
});

console.log(response.choices[0].message.content);
console.log(response.usage);

Streaming

With stream: true, the response uses OpenAI-compatible SSE. Text chunks appear in choices[0].delta.content. To receive usage.seconds at the end, also set:

json
{
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}

The final event that contains usage may have an empty choices array. Check the array before reading a delta.

Limits and Notes

  • Maximum audio duration: 5 minutes. Maximum file size: 10 MB.
  • Audio URLs must be directly accessible from the public internet without authentication.
  • Base64 input must include a valid Data URI prefix, such as data:audio/mpeg;base64,.
  • The API returns recognized text but does not return sentence-level or word-level timestamps.
  • Use /v1/chat/completions.

Troubleshooting

Model unavailable

Make sure model is qwen3-asr-flash, then contact your platform administrator to confirm account access.

Audio cannot be read

Make sure the URL is anonymously accessible, or use a Base64 Data URI. Verify that the audio is within the duration and file-size limits.

Invalid request body

Make sure content is an array, the audio object uses type: "input_audio", and asr_options is at the top level.