Expand description
§reka
Async Rust SDK for Reka API.
§Installation
[dependencies]
reka = "0.1.0"By default the crate uses reqwest with rustls-tls. To use platform-native TLS instead:
[dependencies]
reka = { version = "0.1.0", default-features = false, features = ["native-tls"] }§Authentication
Set REKA_API_KEY in your environment:
export REKA_API_KEY=...You can then create a client with Client::from_env(), or build one explicitly with Client::new(...) or Client::with_config(...).
§Quick Start
use reka::{ChatMessage, Client, CreateChatCompletionArgs, ModelId};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), reka::RekaError> {
let client = Client::from_env()?;
let args = CreateChatCompletionArgs::new(
ModelId::flash(),
vec![ChatMessage::user("Reply with the single word OK.")],
)
.with_max_tokens(32);
let response = client.chat().create(&args).await?;
let content = response.choices[0]
.message
.content
.as_deref()
.unwrap_or_default();
println!("{content}");
Ok(())
}§Streaming
Streaming uses the same args type as non-streaming chat requests:
use reka::{ChatMessage, Client, CreateChatCompletionArgs, ModelId};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), reka::RekaError> {
let client = Client::from_env()?;
let args = CreateChatCompletionArgs::new(
ModelId::flash(),
vec![ChatMessage::user("Stream a short greeting.")],
);
let _stream = client.chat().stream(&args).await?;
Ok(())
}§Research
Research requests build on top of chat-style messages with additional research options:
use reka::{
ChatMessage, Client, CreateResearchArgs, ModelId, UserLocation, WebSearchOptions,
};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), reka::RekaError> {
let client = Client::from_env()?;
let args = CreateResearchArgs::new(
ModelId::flash_research(),
vec![ChatMessage::user("Summarize the latest Reka product announcements.")],
)
.with_web_search(
WebSearchOptions::new()
.with_max_uses(3)
.with_user_location(
UserLocation::new()
.with_country("US")
.with_timezone("America/Los_Angeles"),
),
);
let _response = client.research().create(&args).await?;
Ok(())
}§Vision
Vision APIs follow the same pattern with typed *Args values:
use reka::{Client, DeleteVideoArgs, GetVideoArgs, ListVideosArgs};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), reka::RekaError> {
let client = Client::from_env()?;
let _health = client.vision().health().await?;
let _videos = client
.vision()
.videos()
.list(&ListVideosArgs::new().with_ids(["video-1", "video-2"]))
.await?;
let _video = client
.vision()
.videos()
.get(&GetVideoArgs::new("video-1"))
.await?;
let _deleted = client
.vision()
.videos()
.delete(&DeleteVideoArgs::new("video-2"))
.await?;
Ok(())
}§Configuration
Use ClientConfig when you need custom base URLs, timeouts, headers, or a custom user agent:
use std::time::Duration;
use reka::{Client, ClientConfig};
let config = ClientConfig::builder("test-api-key")
.timeout(Duration::from_secs(10))
.connect_timeout(Duration::from_secs(3))
.build()?;
let client = Client::with_config(config)?;
assert_eq!(client.config().timeout(), Duration::from_secs(10));§Notes
- The crate is async and expects a Tokio runtime.
- Use
ModelId::flash(),ModelId::core(),ModelId::edge(), and related helpers for common model IDs. - Unknown API fields are preserved in
extramaps across most response types. - Docs for the raw HTTP API are intentionally not exposed; the public surface is the typed client API.
§License
MIT
Re-exports§
pub use chat::ChatChoice;pub use chat::ChatClient;pub use chat::ChatDelta;pub use chat::ChatMessage;pub use chat::ChatResponseMessage;pub use chat::ChatStream;pub use chat::ChatStreamChoice;pub use chat::ChatStreamEvent;pub use chat::ChatTool;pub use chat::ContentPart;pub use chat::CreateChatCompletionArgs;pub use chat::CreateChatCompletionResponse;pub use chat::FunctionDefinition;pub use chat::MediaSource;pub use chat::MessageContent;pub use chat::TokenUsage;pub use chat::ToolCall;pub use chat::ToolCallDelta;pub use chat::ToolCallDeltaFunction;pub use chat::ToolCallFunction;pub use research::CreateResearchArgs;pub use research::ParallelThinkingOptions;pub use research::ResearchClient;pub use research::ResearchOptions;pub use research::UserLocation;pub use research::WebSearchOptions;pub use vision::DeleteVideoArgs;pub use vision::DeleteVideoResponse;pub use vision::GetVideoArgs;pub use vision::ListVideosArgs;pub use vision::Video;pub use vision::VideoId;pub use vision::VideoMetadata;pub use vision::VisionClient;pub use vision::VisionHealth;pub use vision::VisionVideosClient;
Modules§
- chat
- Chat completions, streaming, and shared chat types.
- research
- Research requests built on the chat completions API.
- vision
- Vision APIs including health checks and video operations.
Structs§
- ApiError
Response - Error and result types returned by this crate.
- Client
- Top-level client used to access the Reka API. Entry point for the typed Reka SDK.
- Client
Config - Client configuration and configuration builder.
Configuration used to build a
crate::Client. - Client
Config Builder - Client configuration and configuration builder.
Builder for
ClientConfig. - Decode
Error - Error and result types returned by this crate.
- Http
Status Error - Error and result types returned by this crate.
- Model
- Models API and model identifiers. A model returned by the models API.
- ModelId
- Models API and model identifiers. Identifier for a Reka model.
- Models
Client - Models API and model identifiers. Handle for the models API.
Enums§
- Config
Error - Error and result types returned by this crate.
- Reka
Error - Error and result types returned by this crate.
Type Aliases§
- Result
- Error and result types returned by this crate.