|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../core/resource'; |
| 4 | +import { APIPromise } from '../core/api-promise'; |
| 5 | +import { RequestOptions } from '../internal/request-options'; |
| 6 | + |
| 7 | +export class Translation extends APIResource { |
| 8 | + /** |
| 9 | + * Translate text from one language to another. |
| 10 | + */ |
| 11 | + translate(body: TranslationTranslateParams, options?: RequestOptions): APIPromise<TranslationResponse> { |
| 12 | + return this._client.post('/v1/translation', { body, ...options }); |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +export interface TranslationRequest { |
| 17 | + /** |
| 18 | + * Whether to use formal or informal language in the translation. See the |
| 19 | + * [list of languages that support formality](https://dev.writer.com/api-guides/api-reference/translation-api/language-support#formality). |
| 20 | + * If the language does not support formality, this parameter is ignored. |
| 21 | + */ |
| 22 | + formality: boolean; |
| 23 | + |
| 24 | + /** |
| 25 | + * Whether to control the length of the translated text. See the |
| 26 | + * [list of languages that support length control](https://dev.writer.com/api-guides/api-reference/translation-api/language-support#length-control). |
| 27 | + * If the language does not support length control, this parameter is ignored. |
| 28 | + */ |
| 29 | + length_control: boolean; |
| 30 | + |
| 31 | + /** |
| 32 | + * Whether to mask profane words in the translated text. See the |
| 33 | + * [list of languages that do not support profanity masking](https://dev.writer.com/api-guides/api-reference/translation-api/language-support#profanity-masking). |
| 34 | + * If the language does not support profanity masking, this parameter is ignored. |
| 35 | + */ |
| 36 | + mask_profanity: boolean; |
| 37 | + |
| 38 | + /** |
| 39 | + * The model to use for translation. |
| 40 | + */ |
| 41 | + model: 'palmyra-translate'; |
| 42 | + |
| 43 | + /** |
| 44 | + * The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) |
| 45 | + * language code of the original text to translate. For example, `en` for English, |
| 46 | + * `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a |
| 47 | + * variant, the code appends the two-digit |
| 48 | + * [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). |
| 49 | + * For example, Mexican Spanish is `es-MX`. See the |
| 50 | + * [list of supported languages and language codes](https://dev.writer.com/api-guides/api-reference/translation-api/language-support). |
| 51 | + */ |
| 52 | + source_language_code: string; |
| 53 | + |
| 54 | + /** |
| 55 | + * The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) |
| 56 | + * language code of the target language for the translation. For example, `en` for |
| 57 | + * English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language |
| 58 | + * has a variant, the code appends the two-digit |
| 59 | + * [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). |
| 60 | + * For example, Mexican Spanish is `es-MX`. See the |
| 61 | + * [list of supported languages and language codes](https://dev.writer.com/api-guides/api-reference/translation-api/language-support). |
| 62 | + */ |
| 63 | + target_language_code: string; |
| 64 | + |
| 65 | + /** |
| 66 | + * The text to translate. Maximum of 100,000 words. |
| 67 | + */ |
| 68 | + text: string; |
| 69 | +} |
| 70 | + |
| 71 | +export interface TranslationResponse { |
| 72 | + /** |
| 73 | + * The result of the translation. |
| 74 | + */ |
| 75 | + data: string; |
| 76 | +} |
| 77 | + |
| 78 | +export interface TranslationTranslateParams { |
| 79 | + /** |
| 80 | + * Whether to use formal or informal language in the translation. See the |
| 81 | + * [list of languages that support formality](https://dev.writer.com/api-guides/api-reference/translation-api/language-support#formality). |
| 82 | + * If the language does not support formality, this parameter is ignored. |
| 83 | + */ |
| 84 | + formality: boolean; |
| 85 | + |
| 86 | + /** |
| 87 | + * Whether to control the length of the translated text. See the |
| 88 | + * [list of languages that support length control](https://dev.writer.com/api-guides/api-reference/translation-api/language-support#length-control). |
| 89 | + * If the language does not support length control, this parameter is ignored. |
| 90 | + */ |
| 91 | + length_control: boolean; |
| 92 | + |
| 93 | + /** |
| 94 | + * Whether to mask profane words in the translated text. See the |
| 95 | + * [list of languages that do not support profanity masking](https://dev.writer.com/api-guides/api-reference/translation-api/language-support#profanity-masking). |
| 96 | + * If the language does not support profanity masking, this parameter is ignored. |
| 97 | + */ |
| 98 | + mask_profanity: boolean; |
| 99 | + |
| 100 | + /** |
| 101 | + * The model to use for translation. |
| 102 | + */ |
| 103 | + model: 'palmyra-translate'; |
| 104 | + |
| 105 | + /** |
| 106 | + * The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) |
| 107 | + * language code of the original text to translate. For example, `en` for English, |
| 108 | + * `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a |
| 109 | + * variant, the code appends the two-digit |
| 110 | + * [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). |
| 111 | + * For example, Mexican Spanish is `es-MX`. See the |
| 112 | + * [list of supported languages and language codes](https://dev.writer.com/api-guides/api-reference/translation-api/language-support). |
| 113 | + */ |
| 114 | + source_language_code: string; |
| 115 | + |
| 116 | + /** |
| 117 | + * The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) |
| 118 | + * language code of the target language for the translation. For example, `en` for |
| 119 | + * English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language |
| 120 | + * has a variant, the code appends the two-digit |
| 121 | + * [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). |
| 122 | + * For example, Mexican Spanish is `es-MX`. See the |
| 123 | + * [list of supported languages and language codes](https://dev.writer.com/api-guides/api-reference/translation-api/language-support). |
| 124 | + */ |
| 125 | + target_language_code: string; |
| 126 | + |
| 127 | + /** |
| 128 | + * The text to translate. Maximum of 100,000 words. |
| 129 | + */ |
| 130 | + text: string; |
| 131 | +} |
| 132 | + |
| 133 | +export declare namespace Translation { |
| 134 | + export { |
| 135 | + type TranslationRequest as TranslationRequest, |
| 136 | + type TranslationResponse as TranslationResponse, |
| 137 | + type TranslationTranslateParams as TranslationTranslateParams, |
| 138 | + }; |
| 139 | +} |
0 commit comments