Crates.io | llm-sdk |
lib.rs | llm-sdk |
version | 0.4.2 |
source | src |
created_at | 2023-11-19 01:00:17.905887 |
updated_at | 2024-01-20 18:16:07.213223 |
description | A simple SDK for OpenAI compatible API. |
homepage | https://github.com/tyrchen/llm-sdk |
repository | https://github.com/tyrchen/llm-sdk |
max_upload_size | |
id | 1040834 |
size | 184,433 |
SDK for OpenAI compatible APIs.
Add llm-sdk
by using cargo add llm-sdk
.
As assistant API is still in Beta and is super slow, so we don't have plan to support it (and relevant file APIs) for now.
Here are some examples of how to use the SDK:
// create image
let sdk = LlmSdk::new("https://api.openai.com/v1", "your-api-key");
let req = CreateImageRequest::new("A happy little tree");
let res = sdk.create_image(req);
// chat completion
let messages = vec![
ChatCompletionMessage::new_system("I can answer any question you ask me.", ""),
ChatCompletionMessage::new_user("What is human life expectancy in the world?", "user1"),
];
let req = ChatCompletionRequest::new(messages);
let res = sdk.chat_completion(req).await?;
For more usage, please check the test cases.