{"id":15175434,"url":"https://github.com/cohere-ai/cohere-typescript","last_synced_at":"2025-05-14T21:08:23.725Z","repository":{"id":39849271,"uuid":"366414821","full_name":"cohere-ai/cohere-typescript","owner":"cohere-ai","description":"The Cohere TypeScript SDK","archived":false,"fork":false,"pushed_at":"2025-04-02T14:46:35.000Z","size":4331,"stargazers_count":140,"open_issues_count":3,"forks_count":20,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-06T16:06:16.984Z","etag":null,"topics":["javascript","nodejs","npm-package","sdk","typescript"],"latest_commit_sha":null,"homepage":"https://docs.cohere.ai","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cohere-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2021-05-11T14:42:23.000Z","updated_at":"2025-04-06T07:11:10.000Z","dependencies_parsed_at":"2023-11-23T13:26:40.584Z","dependency_job_id":"8d576749-5a8b-4eda-863d-29964d94ec87","html_url":"https://github.com/cohere-ai/cohere-typescript","commit_stats":{"total_commits":184,"total_committers":21,"mean_commits":8.761904761904763,"dds":0.7608695652173914,"last_synced_commit":"d08363f0a1889a81905f2d909c2f8e82e8572bdc"},"previous_names":["cohere-ai/cohere-typescript","cohere-ai/cohere-node"],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cohere-ai%2Fcohere-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cohere-ai%2Fcohere-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cohere-ai%2Fcohere-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cohere-ai%2Fcohere-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cohere-ai","download_url":"https://codeload.github.com/cohere-ai/cohere-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248760655,"owners_count":21157402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","nodejs","npm-package","sdk","typescript"],"created_at":"2024-09-27T12:36:36.635Z","updated_at":"2025-04-13T18:34:09.746Z","avatar_url":"https://github.com/cohere-ai.png","language":"TypeScript","readme":"# Cohere TypeScript SDK\n\n![](banner.png)\n\n[![npm shield](https://img.shields.io/npm/v/cohere-ai)](https://www.npmjs.com/package/cohere-ai)\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)\n\nThe Cohere Typescript SDK allows access to Cohere models across many different platforms: the cohere platform, AWS (Bedrock, Sagemaker), Azure, GCP and Oracle OCI. For a full list of support and snippets, please take a look at the [SDK support docs page](https://docs.cohere.com/docs/cohere-works-everywhere).\n\n## Documentation\n\nCohere documentation and API reference is available [here](https://docs.cohere.com/).\n\n## Installation\n\n```\nnpm i -s cohere-ai\n```\n\n## Usage\n\n```typescript\nimport { CohereClient } from \"cohere-ai\";\n\nconst cohere = new CohereClient({\n    token: \"YOUR_API_KEY\",\n});\n\n(async () =\u003e {\n    const chat = await cohere.chat({\n        model: \"command\",\n        message: \"Tell me a story in 5 parts!\",\n    });\n    \n    console.log(chat);\n})();\n```\n\n## Streaming\n\nThe SDK supports streaming endpoints. To take advantage of this feature for chat,\nuse `chatStream`.\n\n```typescript\nimport { CohereClient } from \"cohere-ai\";\n\nconst cohere = new CohereClient({\n    token: \"YOUR_API_KEY\",\n});\n\n(async () =\u003e {\n    const stream = await cohere.chatStream({\n        model: \"command\",\n        message: \"Tell me a story in 5 parts!\",\n    });\n\n    for await (const chat of stream) {\n        if (chat.eventType === \"text-generation\") {\n            process.stdout.write(chat.text);\n        }\n    }\n})();\n```\n\n## Errors\n\nWhen the API returns a non-success status code (4xx or 5xx response),\na subclass of [CohereError](./src/errors/CohereError.ts) will be thrown:\n\n```TypeScript\nimport { CohereClient, CohereError, CohereTimeoutError } from \"cohere-ai\";\n\nconst cohere = new CohereClient({\n    token: \"YOUR_API_KEY\",\n});\n\n(async () =\u003e {\n    try {\n        await cohere.generate(/* ... */);\n    } catch (err) {\n        if (err instanceof CohereTimeoutError) {\n            console.log(\"Request timed out\", err);\n        } else if (err instanceof CohereError) {\n            // catch all errors\n            console.log(err.statusCode);\n            console.log(err.message);\n            console.log(err.body);\n        }\n    }\n})();\n```\n\n## Beta status\n\nThis SDK is in beta, and while we will try to avoid it, there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your package.json file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, the code is generated programmatically. Additions made directly would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!\n\nOn the other hand, contributions to the README are always very welcome!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcohere-ai%2Fcohere-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcohere-ai%2Fcohere-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcohere-ai%2Fcohere-typescript/lists"}