gpt
This crate provides a simple way to interact with the OpenAI API from Rust.
Example
This asynchronous example uses Tokio and enables some optional features, so your Cargo.toml could look like this:
toml
[dependencies]
gpt = { git="https://github.com/Kobayashi-takumi/gpt-rs" }
tokio = { version = "1", features = ["full"] }
And then the code:
```rust
[tokio::main]
async fn main() -> Result<(), Box> {
let client = Client::new(Config {
apikey:"".tostring(),
organization: Some(""),
})?;
let res = Chat::builder()
.config(Default::default())
.request(vec!["hi".into()])
.build()?
.execute(&client)
.await?;
}
```
```rust
[tokio::main]
async fn main() -> Result<(), Box> {
let client = Client::new(Config {
apikey:"".tostring(),
organization: Some("".to_string()),
})?;
let res = Chat::builder()
.config(Default::default())
.request(vec!["hi".into()])
.build()?
.execute(&client)
.await?;
Ok(())
}
```
```rust
[tokio::main]
async fn main() -> Result<(), Box> {
let client = Client::new(Config {
apikey:"".tostring(),
organization: Some(""),
})?;
let res = CreateImage::builder()
.request("doc".into())
.build()?
.execute(&client)
.await;
Ok(())
}
```