Documentation
¶
Index ¶
- func PollResults[T any](ctx context.Context, t transport.Transport, taskID uuid.UUID, ...) ([]T, error)
- type APIKeyInfo
- type AccountManagementRequest
- type AccountResult
- type AccountUsage
- type AudioInferenceRequest
- type AudioInferenceResult
- type AudioSettings
- type Client
- type DeliveryMethod
- type FrameImage
- type GetResponseRequest
- type ImageInferenceRequest
- type ImageInferenceResult
- type Message
- type ModelResult
- type ModelSchema
- type ModelSearchRequest
- type ModelSearchResponse
- type OutputFormat
- type PingRequest
- type PingResult
- type TaskType
- type TeamMember
- type TextInferenceRequest
- type TextInferenceResult
- type TextInferenceUsage
- type UsagePeriod
- type VideoInferenceRequest
- type VideoInferenceResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PollResults ¶
func PollResults[T any](ctx context.Context, t transport.Transport, taskID uuid.UUID, interval time.Duration, logger *slog.Logger, parse func(json.RawMessage) (T, bool)) ([]T, error)
PollResults polls for async task results by repeatedly calling GetResponse via the transport until the parse function yields at least one result, the context is cancelled, or a fatal error (auth or API error) is returned.
Types ¶
type APIKeyInfo ¶ added in v0.7.0
type APIKeyInfo struct {
Name string `json:"name"`
APIKey string `json:"apiKey"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"createdAt"`
LastUsedAt time.Time `json:"lastUsedAt,omitempty"`
Requests int `json:"requests,omitempty"`
}
APIKeyInfo describes a single API key on the account.
type AccountManagementRequest ¶ added in v0.7.0
type AccountManagementRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Operation string `json:"operation"`
}
AccountManagementRequest is the request payload for the accountManagement task.
type AccountResult ¶
type AccountResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
OrganizationUUID uuid.UUID `json:"organizationUUID"`
OrganizationName string `json:"organizationName"`
AIRSource string `json:"AIRSource,omitempty"`
Balance float64 `json:"balance"`
Team []TeamMember `json:"team,omitempty"`
APIKeys []APIKeyInfo `json:"apiKeys,omitempty"`
Usage AccountUsage `json:"usage"`
}
AccountResult is the response from accountManagement getDetails.
type AccountUsage ¶
type AccountUsage struct {
Total UsagePeriod `json:"total"`
Today UsagePeriod `json:"today"`
Last7Days UsagePeriod `json:"last7Days"`
Last30Days UsagePeriod `json:"last30Days"`
}
type AudioInferenceRequest ¶
type AudioInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Model string `json:"model"`
PositivePrompt string `json:"positivePrompt,omitempty"`
Duration float64 `json:"duration"`
NumberResults int `json:"numberResults"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
DeliveryMethod DeliveryMethod `json:"deliveryMethod,omitempty"`
IncludeCost bool `json:"includeCost,omitempty"`
AudioSettings *AudioSettings `json:"audioSettings,omitempty"`
}
AudioInferenceRequest contains fields for the audioInference task type.
type AudioInferenceResult ¶
type AudioInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Status string `json:"status,omitempty"`
AudioUUID uuid.UUID `json:"audioUUID"`
AudioURL string `json:"audioURL,omitempty"`
Cost float64 `json:"cost,omitempty"`
}
AudioInferenceResult is a single audio result from the API.
type AudioSettings ¶
type AudioSettings struct {
SampleRate int `json:"sampleRate,omitempty"`
Bitrate int `json:"bitrate,omitempty"`
}
AudioSettings configures technical audio quality parameters.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides business-logic methods for the Runware API. It delegates wire-level communication to the injected Transport.
func (*Client) AccountDetails ¶
func (c *Client) AccountDetails(ctx context.Context) (*AccountResult, error)
AccountDetails fetches account information.
func (*Client) ModelSearch ¶
func (c *Client) ModelSearch(ctx context.Context, req ModelSearchRequest) (*ModelSearchResponse, error)
ModelSearch searches for models on the Runware platform.
type DeliveryMethod ¶
type DeliveryMethod string
DeliveryMethod specifies how task results are delivered.
const DeliveryMethodAsync DeliveryMethod = "async"
type FrameImage ¶
type FrameImage struct {
InputImage string `json:"inputImage"`
Frame any `json:"frame"` // "first", "last", or int
}
FrameImage constrains a specific frame with an input image.
type GetResponseRequest ¶
type GetResponseRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
}
GetResponseRequest is used to poll for async task results.
type ImageInferenceRequest ¶
type ImageInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
PositivePrompt string `json:"positivePrompt"`
NegativePrompt string `json:"negativePrompt,omitempty"`
Model string `json:"model"`
Width int `json:"width"`
Height int `json:"height"`
Steps int `json:"steps,omitempty"`
NumberResults int `json:"numberResults"`
CFGScale float64 `json:"CFGScale,omitempty"`
Scheduler string `json:"scheduler,omitempty"`
Seed int64 `json:"seed,omitempty"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
InputImage string `json:"inputImage,omitempty"`
Strength float64 `json:"strength,omitempty"`
MaskImage string `json:"maskImage,omitempty"`
}
ImageInferenceRequest contains fields for the imageInference task type.
type ImageInferenceResult ¶
type ImageInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
ImageUUID uuid.UUID `json:"imageUUID"`
ImageURL string `json:"imageURL"`
Seed int64 `json:"seed"`
}
ImageInferenceResult is a single image result from the API.
type ModelResult ¶
type ModelResult struct {
Name string `json:"name"`
AIR string `json:"air"`
Tags []string `json:"tags"`
ImageURL string `json:"imageURL"`
ThumbnailURL string `json:"thumbnailURL"`
Category string `json:"category"`
Private bool `json:"private"`
Primary bool `json:"primary"`
BaseModel string `json:"baseModel,omitempty"`
Version string `json:"version"`
Architecture string `json:"architecture"`
NSFWLevel int `json:"nsfwLevel"`
Type string `json:"type,omitempty"`
DefaultWeight float64 `json:"defaultWeight,omitempty"`
DefaultWidth int `json:"defaultWidth,omitempty"`
DefaultHeight int `json:"defaultHeight,omitempty"`
DefaultSteps int `json:"defaultSteps,omitempty"`
DefaultScheduler string `json:"defaultScheduler,omitempty"`
DefaultCFG float64 `json:"defaultCFG,omitempty"`
DefaultStrength float64 `json:"defaultStrength,omitempty"`
PositiveTriggerWords string `json:"positiveTriggerWords,omitempty"`
NegativeTriggerWords string `json:"negativeTriggerWords,omitempty"`
}
ModelResult is a single model from the search results.
type ModelSchema ¶ added in v0.7.0
type ModelSchema struct {
RequestSchema json.RawMessage `json:"requestSchema"`
ResponseSchema json.RawMessage `json:"responseSchema"`
Documentation string `json:"documentation"`
}
ModelSchema is the response from the schema resolve endpoint.
func FetchModelSchema ¶ added in v0.7.0
func FetchModelSchema(ctx context.Context, air string) (*ModelSchema, error)
FetchModelSchema retrieves the request and response JSON Schema for the given AIR identifier from the Runware schema service. This endpoint is unauthenticated and separate from the inference API transport.
func (ModelSchema) MarshalYAML ¶ added in v0.7.0
func (s ModelSchema) MarshalYAML() (any, error)
MarshalYAML converts ModelSchema to a form the YAML encoder can handle. json.RawMessage fields are []byte, which would otherwise be base64-encoded by the YAML encoder. Unmarshaling them to any first produces native Go maps/slices that YAML can render as structured output.
type ModelSearchRequest ¶
type ModelSearchRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Search string `json:"search,omitempty"`
Tags []string `json:"tags,omitempty"`
Category string `json:"category,omitempty"`
Type string `json:"type,omitempty"`
Architecture string `json:"architecture,omitempty"`
Conditioning string `json:"conditioning,omitempty"`
Visibility string `json:"visibility,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
ModelSearchRequest contains fields for the modelSearch task type.
type ModelSearchResponse ¶
type ModelSearchResponse struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Results []ModelResult `json:"results"`
TotalResults int `json:"totalResults"`
}
ModelSearchResponse is the response wrapper from modelSearch.
type OutputFormat ¶
type OutputFormat string
OutputFormat specifies the media output format.
const ( OutputFormatPNG OutputFormat = "png" OutputFormatJPG OutputFormat = "jpg" OutputFormatJPEG OutputFormat = "jpeg" OutputFormatWebP OutputFormat = "webp" OutputFormatMP3 OutputFormat = "mp3" OutputFormatMP4 OutputFormat = "mp4" OutputFormatText OutputFormat = "text" OutputFormatJSON OutputFormat = "json" )
type PingRequest ¶ added in v0.7.0
type PingRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
}
PingRequest is the request payload for the ping task.
type PingResult ¶
PingResult is the response from a ping task.
type TaskType ¶
type TaskType string
TaskType identifies the Runware API task. Set by client methods; not exposed to callers.
type TeamMember ¶ added in v0.7.0
type TeamMember struct {
Name string `json:"name"`
Email string `json:"email"`
Roles []string `json:"roles"`
JoinedAt time.Time `json:"joinedAt,omitempty"`
}
TeamMember is a member of the organization.
type TextInferenceRequest ¶
type TextInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"maxTokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"topP,omitempty"`
TopK int `json:"topK,omitempty"`
Seed int64 `json:"seed,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
NumberResults int `json:"numberResults,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
IncludeCost bool `json:"includeCost,omitempty"`
}
TextInferenceRequest contains fields for the textInference task type.
type TextInferenceResult ¶
type TextInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Text string `json:"text"`
FinishReason string `json:"finishReason,omitempty"`
Usage TextInferenceUsage `json:"usage"`
Cost float64 `json:"cost,omitempty"`
}
TextInferenceResult is a single text result from the API.
type TextInferenceUsage ¶
type TextInferenceUsage struct {
InputTokens int `json:"inputTokens,omitempty"`
OutputTokens int `json:"outputTokens,omitempty"`
TotalTokens int `json:"totalTokens,omitempty"`
}
TextInferenceUsage contains token usage statistics.
type UsagePeriod ¶
type VideoInferenceRequest ¶
type VideoInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Model string `json:"model"`
PositivePrompt string `json:"positivePrompt,omitempty"`
NegativePrompt string `json:"negativePrompt,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration float64 `json:"duration,omitempty"`
Steps int `json:"steps,omitempty"`
CFGScale float64 `json:"CFGScale,omitempty"`
Seed int64 `json:"seed,omitempty"`
NumberResults int `json:"numberResults,omitempty"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
DeliveryMethod DeliveryMethod `json:"deliveryMethod,omitempty"`
FrameImages []FrameImage `json:"frameImages,omitempty"`
IncludeCost bool `json:"includeCost,omitempty"`
}
VideoInferenceRequest contains fields for the videoInference task type.
type VideoInferenceResult ¶
type VideoInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Status string `json:"status,omitempty"`
VideoUUID uuid.UUID `json:"videoUUID"`
VideoURL string `json:"videoURL,omitempty"`
MediaUUID uuid.UUID `json:"mediaUUID"`
MediaURL string `json:"mediaURL,omitempty"`
Seed int64 `json:"seed,omitempty"`
Cost float64 `json:"cost,omitempty"`
}
VideoInferenceResult is a single video result from the API.