{"id":13497022,"url":"https://github.com/uiuifree/rust-openai-chatgpt-api","last_synced_at":"2025-03-28T21:31:53.601Z","repository":{"id":224650130,"uuid":"621219786","full_name":"uiuifree/rust-openai-chatgpt-api","owner":"uiuifree","description":"\"rust-openai-chatgpt-api\" is a Rust library for accessing the ChatGPT API, a powerful NLP platform by OpenAI. The library provides a simple and efficient interface for sending requests and receiving responses, including chat. It uses reqwest and serde for HTTP requests and JSON serialization. ","archived":false,"fork":false,"pushed_at":"2023-03-30T09:19:15.000Z","size":12,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T07:42:04.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uiuifree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-03-30T08:20:42.000Z","updated_at":"2025-01-24T18:25:46.000Z","dependencies_parsed_at":"2024-02-27T03:48:06.188Z","dependency_job_id":null,"html_url":"https://github.com/uiuifree/rust-openai-chatgpt-api","commit_stats":null,"previous_names":["uiuifree/rust-openai-chatgpt-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiuifree%2Frust-openai-chatgpt-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiuifree%2Frust-openai-chatgpt-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiuifree%2Frust-openai-chatgpt-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiuifree%2Frust-openai-chatgpt-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uiuifree","download_url":"https://codeload.github.com/uiuifree/rust-openai-chatgpt-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246105149,"owners_count":20724261,"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":[],"created_at":"2024-07-31T20:00:21.110Z","updated_at":"2025-03-28T21:31:53.324Z","avatar_url":"https://github.com/uiuifree.png","language":"Rust","funding_links":[],"categories":["Core Libraries","Frameworks","Machine Learning","Open API","API Clients"],"sub_categories":["提示语（魔法）"],"readme":"# ChatGPT API Rust Library\n\n![Crates.io](https://img.shields.io/crates/v/openai_chatgpt_api?style=flat-square)\n![GitHub](https://img.shields.io/github/license/openai-rs/openai-api?style=flat-square)\n\n\n## Overview\n\nThis Rust library provides a simple and efficient way to interact with the ChatGPT API, which is a state-of-the-art NLP\nplatform that can generate human-like responses to text queries. The library provides a convenient interface for sending\nrequests and receiving responses from the ChatGPT API, allowing developers to easily integrate the API into their\nRust-based projects.\n\n## Features\n\n- Easy-to-use API for sending requests and receiving responses.\n- Provides responses in multiple formats, including text and JSON.\n- Supports multiple endpoints and response languages.\n\n  |API|Support|\n  |---|---|\n  |Models|✔️|\n  |Completions|✔️|\n  |Chat|✔️|\n  |Edits|✔️|\n  |Images|✔️|\n  |Embeddings|✔️|\n  |Audio|✔️|\n___\n\n\n## Getting Started\nTo get started, you will need an API key from OpenAI. You can obtain an API key by visiting the [OpenAI API page](https://platform.openai.com/docs/api-reference/authentication) and following the instructions there.\n\nOnce you have an API key, you can install the library using Cargo:\n\n\n\n## Installation\n\nTo use this library, add the following to your `Cargo.toml` file:\n\n```toml\n[dependencies]\nopenai_chatgpt_api = \"0.1\"\n```\n\nThen, add the following to your Rust code:\n\n```rust\nuse openai_chatgpt_api::ChatGPT;\nlet chatgpt = ChatGpt::new(\"YOUR_API_KEY_HERE\");\nlet request = ChatGptRequestChatCompletions::new(\n    \"gpt-3.5-turbo\",\n    vec![\n        ChatGptChatFormat::new_system(\"Rust OSS開発者\"),\n        ChatGptChatFormat::new_user(\"ChatGPT API のRustライブラリを作ったのでエンジニアが好みそうなReadmeを作って欲しい。\"),\n    ]\n);\n\nlet res = chatgpt.chat_completions(\u0026request).await.unwrap();\nprintln!(\"{:?}\", response);\n```\n\nYou can replace `\"YOUR_API_KEY_HERE\"` with your actual API key, which can be obtained from the ChatGPT API website.\n\n## Usage\n\n### Creating a New ChatGPT Object\n\nTo use the ChatGPT API Rust library, you first need to create a new `ChatGPT` object. You can do this using the\nfollowing code:\n\n```rust\nuse openai_chatgpt_api::ChatGPT;\nlet chatgpt = ChatGpt::new(\"YOUR_API_KEY_HERE\");\n```\n\nReplace `\"YOUR_API_KEY_HERE\"` with your actual API key.\n\n### Models List\nHere is an example of how to use the models_list method to retrieve a list of all available models:\n\n```rust\nlet models = chatgpt.models_list().await.unwrap();\nlet value = models.to_value();\n```\n\n### Models Retrieve\n\n```rust\nlet model = .models_retrieve(\"text-davinci-003\").await;\nlet value = model.to_value();\n```\n\n### Chatting\nHere is an example of how to use the library to chat with the ChatGPT API:\n\n```rust\nlet request = ChatGptRequestChatCompletions::new(\n    \"gpt-3.5-turbo\",\n    vec![\n        ChatGptChatFormat::new_system(\"Rust OSS開発者\"),\n        ChatGptChatFormat::new_user(\"ChatGPT API のRustライブラリを作ったのでエンジニアが好みそうなReadmeを作って欲しい。\"),\n    ]\n);\n\nlet res = chatgpt.chat_completions(\u0026request).await.unwrap();\nprintln!(\"{:?}\", response.to_value());\n```\n\n\n\n## Contributing\nPull requests are welcome! If you have any questions or issues, please open an issue on the [GitHub repository](https://github.com/uiuifree/rust-openai-chatgpt-api).\n\n## License\nThis library is licensed under the MIT License. See the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuiuifree%2Frust-openai-chatgpt-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuiuifree%2Frust-openai-chatgpt-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuiuifree%2Frust-openai-chatgpt-api/lists"}