Skip to main content

Crate basal_client

Crate basal_client 

Source
Expand description

Async HTTP client for the native Basal endpoint (POST /v1/basal).

Reuse a Client to share its connection pool. The server validates requests and computes decisions; this crate preserves native probabilities and confidence. No GPU runtime or automatic retries are needed. See examples/decide.rs for usage. Dropping an in-flight future cancels the client-side request.

Macros§

questions
Build a named request shape with inferred, checked answer fields.

Structs§

ActAnswer
Checked act answer.
ActKind
Result marker for Act questions.
ActOptions
Act options. Omitted criteria use true/false outcomes.
Answer
Native answer. Fields used by other question types are absent. Unknown fields are retained in extra.
Batch
Durable batch state; nullable timestamps are Unix seconds. Future status strings remain readable.
BatchErrorEntry
A batch-level validation error.
BatchErrors
Bounded list of validation errors.
BatchExpiresAfter
Retention of each output/error file from its creation.
BatchInputLine
One JSONL input record. Serialize each record followed by LF; upload exact bytes if already encoded.
BatchListOptions
Limits and cursor of one list request. The SDK never auto-paginates.
BatchPage
One cursor page, ordered by creation time and id descending.
BatchRequestCounts
Counts after validation. Failed also includes expired records.
BatchResultError
Non-execution error of a result record.
BatchResultLine
One result JSONL line; native success and error response bodies remain arbitrary JSON objects.
BatchResultResponse
Response portion of a result line.
BatchResults
Result cursor. Buffers one file at a time; parsing does not create a second collection of all records. No background task or connection is retained between next calls. Dropping an in-flight next cancels that request; discard the cursor after cancellation rather than resuming uncertain I/O.
BatchResultsOptions
Per-file buffering allowance for the results cursor.
BatchWaitOptions
Explicit polling settings. The deadline covers both retrieval requests and sleeps.
Batches
Batches resource. Workflow polling happens only on an explicit wait call.
ChoiceAnswer
Checked choice answer.
ChoiceKind
Result marker for Choice questions.
ChoiceOptions
Choice display options.
ClaimResult
Per-claim calibrated verdict.
ClassifyAnswer
Checked single- or multi-label classification.
ClassifyKind
Result marker for Classify tasks.
ClassifyOptions
Experimental classification options.
Client
Cloneable, pooled HTTP/1 client with verified TLS. No redirects, automatic retries or environment proxies. DNS hostnames must be ASCII (use punycode for IDN). A Tokio runtime is required for requests.
ClientOptions
Connection configuration. The API key is intentionally not printable through Debug.
CompressAnswer
Checked extractive compression.
CompressKind
Result marker for Compress tasks.
CompressOptions
Extractive compression options.
CompressionUnit
One compression unit in the original text.
CreateBatchFromRequests
A simplified create request. The SDK serializes and uploads these records before creating the batch. JSONL is buffered in memory, limited to 50,000 records and 200 MB; the upload adds a multipart copy.
CreateBatchRequest
Create a batch from an uploaded JSONL input. Use Self::new for native defaults.
DecisionOptions
Decision routing/preprocessing options.
DecisionRequest
Native inference request. A missing model uses the server’s default; basal-rs accepts a model name.
DecisionResponse
Native inference result keyed by question ID.
DeletedFile
Confirmation of a file deletion.
DynamicSchema
Schema for a runtime-keyed Questions map.
EvidenceOptions
Supporting spans for noul and score.
EvidenceSpan
Supporting span in the original state.
ExtractAnswer
Checked structured extraction.
ExtractField
Extracted field, including missing values and source provenance.
ExtractKind
Result marker for Extract tasks.
FileObject
One stored input or result file. Timestamps are Unix seconds.
FileUploadOptions
Optional upload retention. The input itself is always uploaded with purpose batch.
Files
Files resource. Borrows the pooled client; never opens local paths or remote URLs.
MediaInput
One inline media item, in request order.
MediaUsage
Media accounting reported by the server.
ModelMetadata
Model metadata. The exact name is accepted by basal-rs as a request’s model.
ModelsResponse
Model discovery result.
MultiAnswer
Checked multi answer.
MultiKind
Result marker for Multi questions.
MultiOptions
Multi options intentionally have no evidence field.
NoulAnswer
Checked yes/no answer.
NoulKind
Result marker for Noul questions.
PreparedQuestions
Ordered question definitions together with their named response shape. Usually constructed by crate::questions!.
Question
Native question. Criteria and cost matrices are JSON objects or arrays; preserve their order. Additional native fields (including future extensions) go in extra.
QuestionSpec
Immutable typed question definition. It can be reused under multiple request keys.
Questions
Ordered heterogeneous request builder. Request keys identify answers, not definition identity.
ScoreAnswer
Checked score answer.
ScoreKind
Result marker for Score questions.
ToolAnswer
Checked tool routing answer. This SDK never executes a selected tool.
ToolKind
Result marker for Tool questions.
ToolOptions
Tool routing options. Definitions are normalized and validated by the server.
ToolRanking
A ranked tool candidate.
TypedDecisionResponse
Validated response retaining request keys and an optional named answer shape.
Usage
Server-reported usage, with native extension fields retained.
VerifyAnswer
Checked claim verification.
VerifyKind
Result marker for Verify tasks.
VerifyOptions
Experimental verification options.

Enums§

AnswerResult
Checked answer selected by a runtime question key.
BatchCreateInput
Mutually exclusive input paths for Batches::create. Prefer the From conversions at the call site.
BatchOperationError
Typed failures of the opt-in workflow helpers. Debug/Display omit documents, bodies and keys.
CompressionUnitKind
Compression segmentation.
Error
Typed SDK failures. Display and Debug omit response bodies and transport details.
ExtractCalibration
Extraction calibration scope; span products are not certified field probabilities.
ExtractSource
Extraction decision source.
FactsMode
Native facts preprocessing mode.
Language
Explicit prompt language.
MediaDetail
Image resolution budget.
MediaKind
Supported inline input kinds.
MultiObjective
Multi-set selection objective.
OptionKeys
Display named criterion keys.
QuestionType
A native question type.
ToolExtra
Optional non-tool choices.
Verdict
Claim verification verdict.

Traits§

AnswerKind
Closed association between a question and its required result fields.
AnswerSchema
Constructs borrowed answer fields for a request shape.
QuestionSet
Request questions accepted by crate::Client::decide.

Functions§

act
Act over true/false outcomes with default options.
act_with_options
Select an action from a full cost matrix. Omitted criteria use true/false outcomes.
choice
Choose from 2–255 options with default display settings.
choice_with_options
Choose one of 2–255 ordered named options.
classify
Classify using a label object or ordered list, normalized by the server.
compress
Compress verbatim source units; the model chooses units, it does not generate text.
extract
Extract enum, boolean, scalar and nested object fields from a JSON schema.
multi
Multi selection with default threshold and no count limits.
multi_with_options
Select labels independently; options have no evidence.
noul
Yes/no probability with default options.
noul_with_options
Read a yes/no probability.
score
Score over ordered levels with default options.
score_with_options
Score over 2–255 ordered text levels.
tool
Select one tool with default options; does not execute it.
tool_with_options
Select tools from OpenAI, MCP or Anthropic definition objects.
verify
Verify an ordered map or list of claims.

Type Aliases§

ActQuestion
A typed act question.
Automation
Certified automation by requested error target. None is an unavailable task certificate.
ChoiceQuestion
A typed choice question.
ClassifyQuestion
Classification question definition.
CompressQuestion
Compression question definition.
CostMatrix
Explicit action/outcome cost matrix.
ExtractQuestion
Extraction question definition.
MultiQuestion
A typed multi question.
NoulQuestion
A typed yes/no question.
ScoreQuestion
A typed score question.
ToolQuestion
Tool routing definition.
VerifyQuestion
Verification question definition.