llm_kit_togetherai/lib.rs
1//! Together AI provider implementation for the LLM Kit.
2//!
3//! This crate provides a provider implementation for Together AI's extensive collection of
4//! open-source models, supporting chat, embeddings, image generation, and reranking.
5//!
6//! # Features
7//!
8//! - Chat completions with Llama, Mistral, Qwen, DeepSeek, and more
9//! - Traditional text completion interface
10//! - Text embeddings for semantic search
11//! - Image generation with FLUX and Stable Diffusion
12//! - Document reranking for improved search results
13//!
14//! # Examples
15//!
16//! ## Basic Usage with Client Builder (Recommended)
17//!
18//! ```no_run
19//! use llm_kit_togetherai::TogetherAIClient;
20//!
21//! // Create a provider using the client builder
22//! let provider = TogetherAIClient::new()
23//! .api_key("your-api-key")
24//! .build();
25//!
26//! let model = provider.chat_model("meta-llama/Llama-3.3-70B-Instruct-Turbo");
27//! ```
28//!
29//! ## Alternative: Direct Instantiation
30//!
31//! ```no_run
32//! use llm_kit_togetherai::{TogetherAIProvider, TogetherAIProviderSettings};
33//!
34//! // Create a provider using settings
35//! let provider = TogetherAIProvider::new(
36//! TogetherAIProviderSettings::new()
37//! .with_api_key("your-api-key")
38//! );
39//!
40//! let model = provider.chat_model("meta-llama/Llama-3.3-70B-Instruct-Turbo");
41//! ```
42//!
43//! ## Chained Usage
44//!
45//! ```no_run
46//! use llm_kit_togetherai::TogetherAIClient;
47//!
48//! let model = TogetherAIClient::new()
49//! .api_key("your-api-key")
50//! .build()
51//! .chat_model("meta-llama/Llama-3.3-70B-Instruct-Turbo");
52//! ```
53//!
54//! ## Environment Variable
55//!
56//! ```no_run
57//! use llm_kit_togetherai::TogetherAIClient;
58//!
59//! // API key will be read from TOGETHER_AI_API_KEY environment variable
60//! let provider = TogetherAIClient::new()
61//! .load_api_key_from_env()
62//! .build();
63//!
64//! let model = provider.chat_model("meta-llama/Llama-3.3-70B-Instruct-Turbo");
65//! ```
66//!
67//! ## Using the Provider
68//!
69//! This provider implements the `llm-kit-provider` traits. See the examples directory
70//! for detailed usage with `LanguageModel`, `EmbeddingModel`, `ImageModel`, and
71//! `RerankingModel` traits.
72
73/// Chat model options and model IDs.
74pub mod chat_options;
75
76/// Client builder for creating Together AI providers.
77pub mod client;
78
79/// Completion model options and model IDs.
80pub mod completion_options;
81
82/// Embedding model options and model IDs.
83pub mod embedding_options;
84
85/// Image generation models.
86pub mod image;
87
88/// Provider implementation and creation functions.
89pub mod provider;
90
91/// Reranking models.
92pub mod reranking;
93
94/// Settings and configuration for Together AI providers.
95pub mod settings;
96
97// Re-export main types
98pub use client::TogetherAIClient;
99pub use provider::TogetherAIProvider;
100pub use settings::TogetherAIProviderSettings;
101
102// Re-export model IDs
103pub use chat_options::TogetherAIChatModelId;
104pub use completion_options::TogetherAICompletionModelId;
105pub use embedding_options::TogetherAIEmbeddingModelId;
106pub use image::settings::TogetherAIImageModelId;
107pub use reranking::options::{TogetherAIRerankingModelId, TogetherAIRerankingOptions};