{"id":28419193,"url":"https://github.com/deontologician/openai-api-rust","last_synced_at":"2025-07-20T19:34:58.546Z","repository":{"id":52457554,"uuid":"318874358","full_name":"deontologician/openai-api-rust","owner":"deontologician","description":"Rust client for OpenAI API","archived":false,"fork":false,"pushed_at":"2023-09-13T18:19:43.000Z","size":45,"stargazers_count":102,"open_issues_count":9,"forks_count":25,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-05T01:46:18.073Z","etag":null,"topics":["gpt-3","openai","wrapper-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deontologician.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,"zenodo":null}},"created_at":"2020-12-05T19:40:41.000Z","updated_at":"2025-02-11T13:39:40.000Z","dependencies_parsed_at":"2025-06-04T16:09:48.276Z","dependency_job_id":"e1b2313d-69f9-4eb8-9d2a-4fb8b45baa40","html_url":"https://github.com/deontologician/openai-api-rust","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/deontologician/openai-api-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deontologician%2Fopenai-api-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deontologician%2Fopenai-api-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deontologician%2Fopenai-api-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deontologician%2Fopenai-api-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deontologician","download_url":"https://codeload.github.com/deontologician/openai-api-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deontologician%2Fopenai-api-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266187728,"owners_count":23890012,"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":["gpt-3","openai","wrapper-library"],"created_at":"2025-06-04T16:09:30.165Z","updated_at":"2025-07-20T19:34:58.541Z","avatar_url":"https://github.com/deontologician.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openai-api-rust\n![docs](https://docs.rs/openai-api/badge.svg)\n[![Crates.io](https://img.shields.io/crates/v/openai-api.svg)](https://crates.io/crates/openai-api)\n![build](https://github.com/deontologician/openai-api-rust/workflows/Continuous%20Integration/badge.svg)\n\nA simple rust client for OpenAI API.\n\nHas a few conveniences, but is mostly at the level of the API itself.\n\n# Installation\n\n```\n$ cargo add openai-api\n```\n\n# Quickstart\n\n```rust\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let api_token = std::env::var(\"OPENAI_SK\")?;\n    let client = openai_api::Client::new(\u0026api_token);\n    let prompt = String::from(\"Once upon a time,\");\n    println!(\n        \"{}{}\",\n        prompt,\n        client.complete(prompt.as_str()).await?\n    );\n    Ok(())\n}\n```\n# Basic Usage\n\n## Creating a completion\n\nFor simple demos and debugging, you can do a completion and use the `Display` instance of a `Completion` object to convert it to a string:\n\n```rust\nlet response = client.complete_prompt(\"Once upon a time\").await?;\nprintln!(\"{}\", response);\n```\n\nTo configure the prompt more explicitly, you can use the `CompletionArgs` builder:\n\n```rust\nlet args = openai_api::api::CompletionArgs::builder()\n        .prompt(\"Once upon a time,\")\n        .engine(\"text-davinci-003\")\n        .max_tokens(20)\n        .temperature(0.7)\n        .top_p(0.9)\n        .stop(vec![\"\\n\".into()]);\nlet completion = client.complete_prompt(args).await?;\nprintln!(\"Response: {}\", response.choices[0].text);\nprintln!(\"Model used: {}\", response.model);\n```\n\nSee [examples/](./examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeontologician%2Fopenai-api-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeontologician%2Fopenai-api-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeontologician%2Fopenai-api-rust/lists"}