pub struct Synth { /* private fields */ }Expand description
Implementations§
Source§impl Synth
impl Synth
Sourcepub fn new(api_key: impl Into<String>, base_url: Option<&str>) -> Result<Self>
pub fn new(api_key: impl Into<String>, base_url: Option<&str>) -> Result<Self>
Create a new Synth client with explicit credentials.
§Arguments
api_key- Your Synth API keybase_url- Optional custom API base URL
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a client from the SYNTH_API_KEY environment variable.
Examples found in repository?
4async fn main() -> Result<(), synth_ai::Error> {
5 let synth = Synth::from_env()?;
6 let deployments = synth.list_localapi_deployments().await?;
7 println!("deployments={}", deployments.len());
8 for dep in deployments {
9 println!(
10 "{} {} {} {}",
11 dep.deployment_id, dep.name, dep.status, dep.task_app_url
12 );
13 }
14 Ok(())
15}Sourcepub fn api_key_masked(&self) -> String
pub fn api_key_masked(&self) -> String
Get the API key (masked for display).
Sourcepub fn core(&self) -> &SynthClient
pub fn core(&self) -> &SynthClient
Access the underlying core client.
Sourcepub fn environment_pools(&self) -> Result<EnvironmentPoolsClient>
pub fn environment_pools(&self) -> Result<EnvironmentPoolsClient>
Create an Environment Pools client.
Sourcepub fn optimize(&self) -> OptimizeBuilder
pub fn optimize(&self) -> OptimizeBuilder
Start a prompt optimization job.
Returns a builder to configure the optimization.
Sourcepub fn eval(&self) -> EvalBuilder
pub fn eval(&self) -> EvalBuilder
Start an evaluation job.
Returns a builder to configure the evaluation.
Sourcepub async fn tunnel(
&self,
port: u16,
backend: TunnelBackend,
) -> Result<TunnelHandle>
pub async fn tunnel( &self, port: u16, backend: TunnelBackend, ) -> Result<TunnelHandle>
Open a tunnel to a local port.
§Arguments
port- Local port to tunnelbackend- Tunnel backend (cloudflare_managed_lease recommended)
Sourcepub async fn submit_gepa(&self, request: GepaJobRequest) -> Result<String>
pub async fn submit_gepa(&self, request: GepaJobRequest) -> Result<String>
Submit a raw GEPA job.
Sourcepub async fn submit_mipro(&self, request: MiproJobRequest) -> Result<String>
pub async fn submit_mipro(&self, request: MiproJobRequest) -> Result<String>
Submit a raw MIPRO job.
Sourcepub async fn get_job_status(&self, job_id: &str) -> Result<PromptLearningResult>
pub async fn get_job_status(&self, job_id: &str) -> Result<PromptLearningResult>
Get job status.
Sourcepub async fn poll_job(
&self,
job_id: &str,
timeout_secs: f64,
interval_secs: f64,
) -> Result<PromptLearningResult>
pub async fn poll_job( &self, job_id: &str, timeout_secs: f64, interval_secs: f64, ) -> Result<PromptLearningResult>
Poll job until complete.
Sourcepub async fn resume_job(&self, job_id: &str, reason: Option<&str>) -> Result<()>
pub async fn resume_job(&self, job_id: &str, reason: Option<&str>) -> Result<()>
Resume a paused job.
Sourcepub async fn complete(
&self,
request: GraphCompletionRequest,
) -> Result<GraphCompletionResponse>
pub async fn complete( &self, request: GraphCompletionRequest, ) -> Result<GraphCompletionResponse>
Run graph completion.
Sourcepub async fn list_graphs(
&self,
kind: Option<&str>,
limit: Option<i32>,
) -> Result<Value>
pub async fn list_graphs( &self, kind: Option<&str>, limit: Option<i32>, ) -> Result<Value>
List registered graphs.
Sourcepub async fn verify(
&self,
trace: Value,
rubric: Value,
options: Option<VerifierOptions>,
) -> Result<VerifierResponse>
pub async fn verify( &self, trace: Value, rubric: Value, options: Option<VerifierOptions>, ) -> Result<VerifierResponse>
Run verifier on a trace.
Sourcepub async fn rlm_inference(
&self,
query: &str,
context: Value,
options: Option<RlmOptions>,
) -> Result<Value>
pub async fn rlm_inference( &self, query: &str, context: Value, options: Option<RlmOptions>, ) -> Result<Value>
Run RLM (Retrieval-augmented LM) inference.
Sourcepub fn graph_evolve(&self) -> GraphEvolveClient<'_>
pub fn graph_evolve(&self) -> GraphEvolveClient<'_>
Create a Graph Evolve client for advanced operations.
Sourcepub fn graph_evolve_job_from_payload(
&self,
payload: Value,
) -> Result<GraphEvolveJob>
pub fn graph_evolve_job_from_payload( &self, payload: Value, ) -> Result<GraphEvolveJob>
Create a Graph Evolve job from a payload.
Sourcepub fn graph_evolve_job_from_id(&self, job_id: &str) -> Result<GraphEvolveJob>
pub fn graph_evolve_job_from_id(&self, job_id: &str) -> Result<GraphEvolveJob>
Reconnect to a Graph Evolve job by ID.
Sourcepub async fn verify_rubric(
&self,
trace: Value,
rubric: Value,
) -> Result<VerifierResponse>
pub async fn verify_rubric( &self, trace: Value, rubric: Value, ) -> Result<VerifierResponse>
Verify a trace against a rubric with default options.
Sourcepub fn task_app_client(
&self,
base_url: &str,
api_key: Option<&str>,
) -> TaskAppClient
pub fn task_app_client( &self, base_url: &str, api_key: Option<&str>, ) -> TaskAppClient
Create a LocalAPI task app client.
Sourcepub async fn deploy_localapi_from_dir(
&self,
spec: LocalApiDeploySpec,
context_dir: impl AsRef<Path>,
wait_for_ready: bool,
build_timeout_s: f64,
) -> Result<LocalApiDeployResponse>
pub async fn deploy_localapi_from_dir( &self, spec: LocalApiDeploySpec, context_dir: impl AsRef<Path>, wait_for_ready: bool, build_timeout_s: f64, ) -> Result<LocalApiDeployResponse>
Deploy a managed LocalAPI from a context directory.
Sourcepub async fn list_localapi_deployments(
&self,
) -> Result<Vec<LocalApiDeploymentInfo>>
pub async fn list_localapi_deployments( &self, ) -> Result<Vec<LocalApiDeploymentInfo>>
List managed LocalAPI deployments for the current org.
Examples found in repository?
4async fn main() -> Result<(), synth_ai::Error> {
5 let synth = Synth::from_env()?;
6 let deployments = synth.list_localapi_deployments().await?;
7 println!("deployments={}", deployments.len());
8 for dep in deployments {
9 println!(
10 "{} {} {} {}",
11 dep.deployment_id, dep.name, dep.status, dep.task_app_url
12 );
13 }
14 Ok(())
15}Sourcepub async fn get_localapi_deployment(
&self,
deployment_id: &str,
) -> Result<LocalApiDeploymentInfo>
pub async fn get_localapi_deployment( &self, deployment_id: &str, ) -> Result<LocalApiDeploymentInfo>
Fetch a managed LocalAPI deployment by ID.
Sourcepub async fn get_localapi_deployment_status(
&self,
deployment_id: &str,
) -> Result<LocalApiDeployStatus>
pub async fn get_localapi_deployment_status( &self, deployment_id: &str, ) -> Result<LocalApiDeployStatus>
Fetch managed LocalAPI deployment status by ID.
Sourcepub async fn eval_results(&self, job_id: &str) -> Result<Value>
pub async fn eval_results(&self, job_id: &str) -> Result<Value>
Fetch detailed eval results.
Sourcepub async fn download_eval_traces(&self, job_id: &str) -> Result<Vec<u8>>
pub async fn download_eval_traces(&self, job_id: &str) -> Result<Vec<u8>>
Download eval traces as ZIP bytes.
Sourcepub fn trace_uploader(&self) -> Result<TraceUploadClient>
pub fn trace_uploader(&self) -> Result<TraceUploadClient>
Create a trace uploader for large traces.
Sourcepub async fn upload_trace(
&self,
trace: Value,
expires_in_seconds: Option<i64>,
) -> Result<String>
pub async fn upload_trace( &self, trace: Value, expires_in_seconds: Option<i64>, ) -> Result<String>
Upload a trace and return its trace_ref.
Sourcepub async fn stream_job_with_callback<F>(
&self,
job_id: &str,
endpoints: StreamEndpoints,
callback: F,
) -> Result<Value>
pub async fn stream_job_with_callback<F>( &self, job_id: &str, endpoints: StreamEndpoints, callback: F, ) -> Result<Value>
Stream job events with a callback and return final status.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Synth
impl !RefUnwindSafe for Synth
impl Send for Synth
impl Sync for Synth
impl Unpin for Synth
impl !UnwindSafe for Synth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request