{"id":32278002,"url":"https://github.com/vladcto/yandex-gpt-rest-api","last_synced_at":"2026-02-22T12:01:49.822Z","repository":{"id":211624181,"uuid":"729201292","full_name":"vladcto/yandex-gpt-rest-api","owner":"vladcto","description":"A library for using YandexGPT API, such as generating text and obtain embeddings.","archived":false,"fork":false,"pushed_at":"2024-05-04T19:12:48.000Z","size":131,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-10T10:56:07.988Z","etag":null,"topics":["api-client","dart","dart-package","gpt","rest-api","text-generation","yandex-api","yandex-gpt"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/yandex_gpt_rest_api","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vladcto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-08T16:22:11.000Z","updated_at":"2024-06-17T11:51:00.000Z","dependencies_parsed_at":"2026-02-22T12:01:32.988Z","dependency_job_id":null,"html_url":"https://github.com/vladcto/yandex-gpt-rest-api","commit_stats":null,"previous_names":["vladcto/yandex-gpt-rest-api","vladcto/yandex-gpt-rest-sdk"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/vladcto/yandex-gpt-rest-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladcto%2Fyandex-gpt-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladcto%2Fyandex-gpt-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladcto%2Fyandex-gpt-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladcto%2Fyandex-gpt-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladcto","download_url":"https://codeload.github.com/vladcto/yandex-gpt-rest-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladcto%2Fyandex-gpt-rest-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29711634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T10:34:24.778Z","status":"ssl_error","status_checked_at":"2026-02-22T10:32:23.200Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","dart","dart-package","gpt","rest-api","text-generation","yandex-api","yandex-gpt"],"created_at":"2025-10-23T00:15:58.056Z","updated_at":"2026-02-22T12:01:49.803Z","avatar_url":"https://github.com/vladcto.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YandexGPT API Client\n\n[![Test CI](https://github.com/vladcto/yandex-gpt-rest-api/actions/workflows/test_with_coverage.yaml/badge.svg?branch=main\u0026event=push)](https://github.com/vladcto/yandex-gpt-rest-api/actions/workflows/test_with_coverage.yaml)\n[![codecov](https://codecov.io/gh/vladcto/yandex-gpt-rest-api/graph/badge.svg?token=747T4E5KE6)](https://codecov.io/gh/vladcto/yandex-gpt-rest-api)\n\nDart library for working with [YandexGPT API](https://cloud.yandex.ru/en/docs/yandexgpt/).\n\n- [Getting started](#getting-started)\n- [API capabilities](#api-capabilities)\n- [Handling errors](#handling-errors)\n- [Cancel requests](#cancel-requests)\n\n## Getting started\n\nCreate `YandexGptApi` instance.\n\n```dart\n\n// For passing BaseOptions or Dio use other constructors.\nfinal api = YandexGptApi(\n  token: AuthToken.api(\"your_token\"), // or AuthToken.iam\n  // Not necessary, by default uses catalog from AuthToken account.\n  catalog: \"catalog_id?\",\n);\n```\n\nNow you can use the YandexGPT API.\n\n## API calls\n\nThe names of methods `YandexGptApi` are same to the names of API methods.\n\nAvailable API calls:\n\n\u003cdetails\u003e\n\u003csummary\u003eText Generation\u003c/summary\u003e\n\nWhen generating large text with configured small `dio.options.receiveTimeout` a timeout error may occur.\n\n### Generate sync text\n\n```dart\nfinal response = await api.generateText(\n  TextGenerationRequest(\n    model: GModel.yandexGpt('folder_id'),\n    messages: const [\n      Message.system(\"Some joke\"),\n      Message.user(\"Generate joke\"),\n    ],\n  ),\n);\nprint(response.alternatives.first.message);\nprint(response.usage.totalTokens);\n```\n\n### Generate async text\n\nThe `generateAsyncText` returns the [Operation object](https://cloud.yandex.com/en/docs/api-design-guide/concepts/operation).\n\nFor handling `Operation` you can use [getOperationTextGenerate](#fetch-async-generation-status).\n\n```dart\nfinal response = await api.generateAsyncText(\n  TextGenerationRequest(\n    model: GModel.yandexGpt('folder_id'),\n    messages: const [\n      Message.system(\"Some joke\"),\n      Message.user(\"Generate joke\"),\n    ],\n  ),\n);\nprint(response.done);\n```\n\n### Fetch async generation status\n```dart\nfinal asyncText = await api.generateAsyncText(/*request*/);\nfinal response = await api.getOperationTextGenerate(asyncText.id);\nprint(response.done);\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eTokenize\u003c/summary\u003e\n\n### Tokenize completion\n\n```dart\nfinal response = await api.tokenizeCompletion(\n  TextGenerationRequest(\n    model: GModel.yandexGpt('folder_id'),\n    messages: const [\n      Message.system(\"Some joke\"),\n      Message.user(\"Generate joke\"),\n    ],\n  ),\n);\nprint(response.tokens.length);\n```\n\n### Tokenize text\n\n```dart\nfinal response = await api.tokenizeText(\n  TokenizeTextRequest(\n    model: GModel.yandexGpt('folder_id'),\n    text: 'some_response_text',\n  ),\n);\nprint(response.tokens.length);\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEmbeddings\u003c/summary\u003e\n\n### Text embedding\n\n```dart\nfinal response = await api.getTextEmbedding(\n  EmbeddingRequest(\n    model: VModel.documentation('folder_id'),\n    text: 'Some text',\n  ),\n);\nprint(response.embedding);\n```\n\u003c/details\u003e\n\n## Handling errors\n\nIt is enough to catch an error of type `ApiError`.\n\n```dart\ntry {\n  await api.generateText(/*request*/);\n} on ApiError catch (e) {\n  // Handle YandexGPT API errors\n} on DioException catch (e) {\n  // Handle network errors\n}\n```\n\nIf you need information about the error:\n\n```dart\ntry {\n  await api.generateText(/*request*/);\n} on DetailedApiError catch (e) {\n  // Handle DetailedApiError\n} on ShortApiError catch (e) {\n  // Handle ShortApiError\n} on DioException catch (e) {\n  // Handle network errors\n}\n```\n\n## Cancel requests\n\nTo cancel requests use Dio `CancelToken` by passing API requests with `cancelToken` param.\n\nThe handling cancellation is similar to\nthe [example from the Dio doc](https://github.com/cfug/dio/blob/51d0bbb74298f40ef2f54d6109c2510c978f3771/example/lib/cancel_request.dart).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladcto%2Fyandex-gpt-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladcto%2Fyandex-gpt-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladcto%2Fyandex-gpt-rest-api/lists"}