Skip to main content

Common Types and Errors

Speech, translation, interpretation, recording, and image generation share language, audio format, task, callback, and error contracts.

TSAIAudioFormat​

ValueRaw valueDescription
TSAIAudioFormatUnknown-1Unknown format
TSAIAudioFormatNone0No audio in results; inspect file header in configurations
TSAIAudioFormatPcm1PCM
TSAIAudioFormatOpus2Opus
TSAIAudioFormatMp33MP3
TSAIAudioFormatWav4WAV

Raw PCM has no header and requires explicit format, sample-rate, channel, and bit-depth information.

TSAILanguage​

TSAILanguage is shared across AI services and is distinct from the device-UI TSLanguageType.

NameValueNameValue
Unknown-1Auto0
ChineseSimplified1ChineseTraditional2
EnglishUS3EnglishUK4
Japanese5Korean6
French7German8
Spanish9Russian10
Portuguese11Indonesian12
Malay13Filipino14
Thai15Arabic16
Vietnamese17Danish18
Greek19Finnish20
Hindi21Italian22
Dutch23Norwegian24
Polish25Swedish26
Swahili27Turkish28
Bengali29Romanian30
Nepali31Ukrainian32
Czech33Welsh34
Hungarian35Icelandic36
Georgian37Kazakh38
Luxembourgish39Latvian40
Malayalam41Slovak42
Slovenian43Serbian44
Telugu45Catalan46
Tamil47Urdu48
Croatian49Bulgarian50
Lithuanian51Latin52
Maori53Persian54
Azerbaijani55Kannada56
Estonian57Macedonian58
Breton59Basque60
Armenian61Mongolian62
Bosnian63Albanian64
Galician65Marathi66
Punjabi67Sinhala68
Khmer69Shona70
Yoruba71Somali72
Afrikaans73Occitan74
Belarusian75Tajik76
Sindhi77Gujarati78
Amharic79Yiddish80
Lao81Uzbek82
Faroese83HaitianCreole84
Pashto85Turkmen86
NorwegianNynorsk87Maltese88
Sanskrit89Burmese90
Tibetan91Malagasy92
Assamese93Tatar94
Hawaiian95Lingala96
Hausa97Bashkir98
Javanese99Sundanese100

Prefix each short name with TSAILanguage, for example TSAILanguageChineseSimplified.

Auto and Unknown​

  • Auto is valid only for translation or interpretation source-language detection.
  • ASR, recording, and image generation reject Auto.
  • Translation and interpretation targets must be concrete.
  • Unknown usually means unset or current app localization; check each property contract.

BCP-47 mapping​

+ (nullable NSString *)bcp47CodeForLanguage:(TSAILanguage)language;
+ (nullable NSString *)targetBcp47CodeForLanguage:(TSAILanguage)language;
+ (TSAILanguage)languageForBcp47Code:(nullable NSString *)code;

TSAIASRScene​

ValueRaw valueMeaning
TSAIASRSceneUnknown-1Unspecified scene
TSAIASRSceneOnSite1Meetings, interviews, and other on-site recordings
TSAIASRSceneCall2Telephone or VoIP recordings

TSAIChatIntentType​

ValueRaw valueMeaning
Unknown-1Unknown protocol intent; see intentId for the raw value
None0Conversation with no actionable intent
PhotoCapture / PhotoUnderstand1 / 2Capture / understand a photo
VideoStart / VideoStop3 / 4Start / stop video recording
AudioRecord5Start audio recording
VolumeUp / VolumeDown / VolumeSet10 / 11 / 12Volume controls
MusicPlay / MusicStop20 / 21Play / stop music
MusicNext / MusicPrev22 / 23Next / previous track
CallAnswer / CallDecline / CallRecord30 / 31 / 32Call controls
DeviceBatteryQuery / DevicePowerOff40 / 41Query battery / power off device
DialogExit / AgentSwitch / VoiceClone50 / 51 / 52Exit dialog / switch agent / clone voice

Prefix shortened values with TSAIChatIntentType, for example TSAIChatIntentTypePhotoCapture.

Task and callback conventions​

  1. Single tasks usually return a client-generated task ID synchronously.
  2. Partial callbacks may run zero or more times; completion runs once on success, failure, or cancellation.
  3. Completion is the authoritative terminal signal.
  4. Logical cancellation may not stop server-side work, but late results are suppressed.
  5. Callback queues are API-specific; question answering, image generation, and selected Context callbacks are explicitly main-thread.

TSAIErrorDomain​

ErrorCodeDescription
TSAIErrorCodeInvalidParameter1001Invalid parameter
TSAIErrorCodeNotSupported1002Feature not supported
TSAIErrorCodeContextInactive1003Context inactive or stale
TSAIErrorCodeProviderUnavailable1004Provider unavailable
TSAIErrorCodeBridgeUnavailable1005Platform DeviceBridge unavailable
TSAIErrorCodeActivationSuperseded1006Activation superseded by a newer request
TSAIErrorCodeBusy1007Conflicting task is active
TSAIErrorCodeCancelled1008Task cancelled
TSAIErrorCodeAuthorizationRequired1009Provider authorization required
TSAIErrorCodeTaskFailed1010AI task failed
TSAIErrorCodeContentRejected1011Content rejected
TSAIErrorCodeTimeout1012Request timed out
TSAIErrorCodeNetworkUnavailable1013Network unavailable
TSAIErrorCodeInvalidResponse1014Invalid provider response
TSAIErrorCodeAudioRouteUnavailable1015No complete audio route satisfies the request or fallback policy
TSAIErrorCodeAudioRouteMismatch1016Use case, device scene, or reserved route does not match the request
if ([error.domain isEqualToString:TSAIErrorDomain]) {
switch (error.code) {
case TSAIErrorCodeAuthorizationRequired:
TSLog(@"AI authorization is required");
break;
case TSAIErrorCodeNetworkUnavailable:
TSLog(@"Network unavailable");
break;
case TSAIErrorCodeContextInactive:
TSLog(@"Obtain the new activeContext");
break;
default:
TSLog(@"AI operation failed: %@", error.localizedDescription);
break;
}
}

Never log app keys, tokens, device-authentication data, or raw user audio.