Skip to main content

CoreClient

Struct CoreClient 

Source
pub struct CoreClient { /* private fields */ }
Expand description

Synth API client.

This is the main entry point for interacting with the Synth API. It provides access to sub-clients for different API endpoints.

§Example

use synth_ai_core::api::SynthClient;

// Create from environment variable
let client = SynthClient::from_env()?;

// Or with explicit API key
let client = SynthClient::new("sk_live_...", None)?;

// Access sub-clients
let jobs = client.jobs();
let eval = client.eval();
let graphs = client.graphs();

Implementations§

Source§

impl SynthClient

Source

pub fn new( api_key: &str, base_url: Option<&str>, ) -> Result<SynthClient, CoreError>

Create a new Synth client with an API key.

§Arguments
  • api_key - Your Synth API key
  • base_url - Optional base URL (defaults to https://api.usesynth.ai)
§Example
let client = SynthClient::new("sk_live_...", None)?;
Source

pub fn with_timeout( api_key: &str, base_url: Option<&str>, timeout_secs: u64, ) -> Result<SynthClient, CoreError>

Create a new Synth client with custom timeout.

§Arguments
  • api_key - Your Synth API key
  • base_url - Optional base URL
  • timeout_secs - Request timeout in seconds
Source

pub fn from_env() -> Result<SynthClient, CoreError>

Create a client from environment variables.

Reads the API key from SYNTH_API_KEY environment variable. Optionally reads base URL from SYNTH_BACKEND_URL.

§Example
std::env::set_var("SYNTH_API_KEY", "sk_live_...");
let client = SynthClient::from_env()?;
Source

pub async fn from_env_or_mint( allow_mint: bool, base_url: Option<&str>, ) -> Result<SynthClient, CoreError>

Create a client, minting a demo key if needed.

This will:

  1. Try to get an API key from environment
  2. If not found and allow_mint is true, mint a demo key
§Arguments
  • allow_mint - Whether to mint a demo key if no key is found
  • base_url - Optional base URL
Source

pub fn base_url(&self) -> &str

Get the base URL for this client.

Source

pub fn http(&self) -> &HttpClient

Get a reference to the HTTP client.

Source

pub fn jobs(&self) -> JobsClient<'_>

Get a Jobs API client.

Use this to submit, poll, and cancel optimization jobs.

§Example
let job_id = client.jobs().submit_gepa(request).await?;
let result = client.jobs().poll_until_complete(&job_id, 3600.0, 15.0).await?;
Source

pub fn eval(&self) -> EvalClient<'_>

Get an Eval API client.

Use this to run evaluation jobs.

§Example
let job_id = client.eval().submit(request).await?;
let result = client.eval().poll_until_complete(&job_id, 3600.0, 15.0).await?;
Source

pub fn graphs(&self) -> GraphsClient<'_>

Get a Graphs API client.

Use this for graph completions and verifier inference.

§Example
let result = client.graphs().verify(trace, rubric, None).await?;
Source

pub fn graph_evolve(&self) -> GraphEvolveClient<'_>

Get a Graph Evolve API client.

Use this for Graph Evolve / GraphGen optimization endpoints.

Source

pub fn inference(&self) -> InferenceClient<'_>

Get an Inference API client.

Use this for chat completions via the inference proxy.

Source

pub fn localapi(&self) -> LocalApiDeployClient<'_>

Get a LocalAPI Deployments client.

Use this to deploy and manage managed LocalAPI deployments.

Trait Implementations§

Source§

impl Debug for SynthClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more