Documentation
¶
Overview ¶
Package meshapi is a Go client for the MeshAPI AI model gateway.
Quick start ¶
client := meshapi.NewClient(meshapi.Config{
BaseURL: "http://localhost:8000",
Token: "rsk_...",
})
model := "openai/gpt-4o-mini"
resp, err := client.Chat.Completions.Create(ctx, meshapi.ChatCompletionParams{
Model: &model,
Messages: []meshapi.ChatMessage{{Role: "user", Content: "Hello!"}},
})
Package meshapi provides a typed Go client for the MeshAPI AI model gateway.
Index ¶
- Constants
- type AudioOutputOptions
- type BatchListResponse
- type BatchObject
- type BatchRequestItem
- type BatchesResource
- func (r *BatchesResource) Cancel(ctx context.Context, batchID string) (*BatchObject, error)
- func (r *BatchesResource) Create(ctx context.Context, params CreateBatchParams) (*BatchObject, error)
- func (r *BatchesResource) Get(ctx context.Context, batchID string) (*BatchObject, error)
- func (r *BatchesResource) List(ctx context.Context, after *string, limit *int) (*BatchListResponse, error)
- type BuiltinTool
- type ChatCompletionChoice
- type ChatCompletionChunk
- type ChatCompletionChunkChoice
- type ChatCompletionChunkDelta
- type ChatCompletionMessage
- type ChatCompletionParams
- type ChatCompletionResponse
- type ChatMessage
- type ChatResource
- type Client
- type CompareParams
- type CompareResource
- type CompareResponse
- type CompareStreamEvent
- type CompletionsResource
- type Config
- type ContentPart
- type CreateBatchParams
- type CreateTemplateParams
- type EmbeddingItem
- type EmbeddingsParams
- type EmbeddingsResource
- type EmbeddingsResponse
- type EmbeddingsUsage
- type FileObject
- type FilesResource
- func (r *FilesResource) Content(ctx context.Context, fileID string) ([]byte, error)
- func (r *FilesResource) Delete(ctx context.Context, fileID string) error
- func (r *FilesResource) Get(ctx context.Context, fileID string) (*FileObject, error)
- func (r *FilesResource) Upload(ctx context.Context, params UploadBatchFileParams) (*FileObject, error)
- type ImageGenerationChunk
- type ImageGenerationParams
- type ImageGenerationResponse
- type ImageItem
- type ImageOptions
- type ImageURL
- type ImageUsage
- type ImagesResource
- type InputAudio
- type ListModelsParams
- type MeshAPIError
- type ModelCompareResult
- type ModelInfo
- type ModelOverride
- type ModelPricing
- type ModelsResource
- type ProviderPreferences
- type ResponsesFunctionTool
- type ResponsesParams
- type ResponsesResource
- type ResponsesResponse
- type ResponsesStreamEvent
- type ResponsesUsage
- type TemplateSummary
- type TemplatesResource
- func (r *TemplatesResource) Create(ctx context.Context, params CreateTemplateParams) (*TemplateSummary, error)
- func (r *TemplatesResource) Delete(ctx context.Context, id string) error
- func (r *TemplatesResource) Get(ctx context.Context, id string) (*TemplateSummary, error)
- func (r *TemplatesResource) List(ctx context.Context) ([]TemplateSummary, error)
- func (r *TemplatesResource) Update(ctx context.Context, id string, params UpdateTemplateParams) (*TemplateSummary, error)
- type TokenUsage
- type Tool
- type ToolCall
- type ToolCallFunction
- type ToolChoice
- type ToolChoiceFunction
- type ToolChoiceObject
- type ToolFunction
- type UpdateTemplateParams
- type UploadBatchFileParams
- type UsageInfo
Constants ¶
const Version = "0.1.0"
Version is the current SDK version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioOutputOptions ¶ added in v0.1.3
type BatchListResponse ¶ added in v0.1.3
type BatchListResponse struct {
Object string `json:"object"`
Data []BatchObject `json:"data"`
HasMore bool `json:"has_more"`
FirstID *string `json:"first_id,omitempty"`
LastID *string `json:"last_id,omitempty"`
}
type BatchObject ¶ added in v0.1.3
type BatchObject struct {
ID string `json:"id"`
Object *string `json:"object,omitempty"`
Endpoint *string `json:"endpoint,omitempty"`
InputFileID *string `json:"input_file_id,omitempty"`
OutputFileID *string `json:"output_file_id,omitempty"`
Status *string `json:"status,omitempty"`
Model *string `json:"model,omitempty"`
Provider *string `json:"provider,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty"`
CompletedAt *int64 `json:"completed_at,omitempty"`
UsageSynced *bool `json:"usage_synced,omitempty"`
}
type BatchRequestItem ¶ added in v0.1.3
type BatchesResource ¶ added in v0.1.3
type BatchesResource struct {
// contains filtered or unexported fields
}
func (*BatchesResource) Cancel ¶ added in v0.1.3
func (r *BatchesResource) Cancel(ctx context.Context, batchID string) (*BatchObject, error)
func (*BatchesResource) Create ¶ added in v0.1.3
func (r *BatchesResource) Create(ctx context.Context, params CreateBatchParams) (*BatchObject, error)
func (*BatchesResource) Get ¶ added in v0.1.3
func (r *BatchesResource) Get(ctx context.Context, batchID string) (*BatchObject, error)
func (*BatchesResource) List ¶ added in v0.1.3
func (r *BatchesResource) List(ctx context.Context, after *string, limit *int) (*BatchListResponse, error)
type BuiltinTool ¶ added in v0.1.3
type BuiltinTool struct {
Type string `json:"type"`
}
type ChatCompletionChoice ¶
type ChatCompletionChoice struct {
Index int `json:"index"`
Message *ChatCompletionMessage `json:"message,omitempty"`
FinishReason *string `json:"finish_reason,omitempty"`
Logprobs interface{} `json:"logprobs,omitempty"`
}
ChatCompletionChoice is one result choice in a non-streaming response.
type ChatCompletionChunk ¶
type ChatCompletionChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChatCompletionChunkChoice `json:"choices"`
Usage *UsageInfo `json:"usage,omitempty"`
Cost *string `json:"cost,omitempty"`
}
ChatCompletionChunk is a single SSE chunk in a streaming completion.
type ChatCompletionChunkChoice ¶
type ChatCompletionChunkChoice struct {
Index int `json:"index"`
Delta *ChatCompletionChunkDelta `json:"delta,omitempty"`
FinishReason *string `json:"finish_reason,omitempty"`
}
ChatCompletionChunkChoice is one choice in a streaming chunk.
type ChatCompletionChunkDelta ¶
type ChatCompletionChunkDelta struct {
Role *string `json:"role,omitempty"`
Content *string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Audio map[string]interface{} `json:"audio,omitempty"`
}
ChatCompletionChunkDelta is the partial content in a streaming chunk.
type ChatCompletionMessage ¶
type ChatCompletionMessage struct {
Role string `json:"role"`
Content *string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Audio map[string]interface{} `json:"audio,omitempty"`
}
ChatCompletionMessage is a completed message in a non-streaming response.
type ChatCompletionParams ¶
type ChatCompletionParams struct {
Messages []ChatMessage `json:"messages"`
Model *string `json:"model,omitempty"`
Stream *bool `json:"stream,omitempty"`
Template *string `json:"template,omitempty"`
Variables map[string]string `json:"variables,omitempty"`
SessionID *string `json:"session_id,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
Stop interface{} `json:"stop,omitempty"` // string or []string
Seed *int `json:"seed,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
Transforms []string `json:"transforms,omitempty"`
Models []string `json:"models,omitempty"`
User *string `json:"user,omitempty"`
Modality *string `json:"modality,omitempty"`
Image *ImageOptions `json:"image,omitempty"`
AsyncMode *bool `json:"async_mode,omitempty"`
Modalities []string `json:"modalities,omitempty"`
Audio *AudioOutputOptions `json:"audio,omitempty"`
}
ChatCompletionParams is the request body for POST /v1/chat/completions.
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChatCompletionChoice `json:"choices"`
Usage *UsageInfo `json:"usage,omitempty"`
SystemFingerprint *string `json:"system_fingerprint,omitempty"`
}
ChatCompletionResponse is the full non-streaming response body.
type ChatMessage ¶
type ChatMessage struct {
Role string `json:"role"`
Content interface{} `json:"content,omitempty"` // string or []ContentPart
Name *string `json:"name,omitempty"`
ToolCallID *string `json:"tool_call_id,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
ChatMessage represents a single message in the conversation.
type ChatResource ¶
type ChatResource struct {
Completions *CompletionsResource
}
ChatResource groups chat-related sub-resources.
type Client ¶
type Client struct {
Chat *ChatResource
Responses *ResponsesResource
Embeddings *EmbeddingsResource
Compare *CompareResource
Files *FilesResource
Batches *BatchesResource
Models *ModelsResource
Templates *TemplatesResource
Images *ImagesResource
}
Client is the MeshAPI SDK client.
One instance = one auth realm. Use separate instances for different tokens:
inferenceClient := meshapi.New(meshapi.Config{Token: "rsk_..."})
mgmtClient := meshapi.New(meshapi.Config{Token: "<jwt>"})
type CompareParams ¶ added in v0.1.3
type CompareParams struct {
Models []string `json:"models"`
Messages []ChatMessage `json:"messages"`
ModelOverrides []ModelOverride `json:"model_overrides,omitempty"`
ComparisonModel *string `json:"comparison_model,omitempty"`
ComparisonInstructions *string `json:"comparison_instructions,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Stream *bool `json:"stream,omitempty"`
Template *string `json:"template,omitempty"`
Variables map[string]string `json:"variables,omitempty"`
SkipComparison *bool `json:"skip_comparison,omitempty"`
}
type CompareResource ¶ added in v0.1.3
type CompareResource struct {
// contains filtered or unexported fields
}
func (*CompareResource) Create ¶ added in v0.1.3
func (r *CompareResource) Create(ctx context.Context, params CompareParams) (*CompareResponse, error)
func (*CompareResource) Stream ¶ added in v0.1.3
func (r *CompareResource) Stream(ctx context.Context, params CompareParams) (<-chan CompareStreamEvent, <-chan error)
type CompareResponse ¶ added in v0.1.3
type CompareResponse struct {
ComparisonID string `json:"comparison_id"`
Object string `json:"object"`
Created int64 `json:"created"`
Models []string `json:"models"`
Results []ModelCompareResult `json:"results"`
Comparison *string `json:"comparison,omitempty"`
ComparisonModel *string `json:"comparison_model,omitempty"`
ComparisonUsage *TokenUsage `json:"comparison_usage,omitempty"`
ComparisonFallbackUsed bool `json:"comparison_fallback_used"`
TotalLatencyMs int `json:"total_latency_ms"`
Partial bool `json:"partial"`
SkipComparison bool `json:"skip_comparison"`
}
type CompareStreamEvent ¶ added in v0.1.3
type CompareStreamEvent map[string]interface{}
type CompletionsResource ¶
type CompletionsResource struct {
// contains filtered or unexported fields
}
CompletionsResource handles POST /v1/chat/completions.
func (*CompletionsResource) Create ¶
func (r *CompletionsResource) Create(ctx context.Context, params ChatCompletionParams) (*ChatCompletionResponse, error)
Create sends a non-streaming chat completion request and returns the full response.
func (*CompletionsResource) Stream ¶
func (r *CompletionsResource) Stream(ctx context.Context, params ChatCompletionParams) (<-chan ChatCompletionChunk, <-chan error)
Stream opens a streaming chat completion. It returns two channels:
- chunkCh: receives parsed ChatCompletionChunks until [DONE] or error
- errCh: receives at most one error, then is closed
Both channels are always closed when the stream finishes. Callers must drain chunkCh before reading errCh, or use a select loop.
Streams are NEVER retried. On failure, catch the error from errCh and restart a new Stream call if reconnection is needed.
type Config ¶
type Config struct {
// BaseURL is the MeshAPI gateway base URL (required).
BaseURL string
// Token is the Bearer token for this auth realm (required).
Token string
// TimeoutMs is the request timeout in milliseconds (default 60_000).
// For streaming requests this applies to TTFB only.
TimeoutMs *int
// MaxRetries is the number of retry attempts on retryable errors (default 3).
MaxRetries *int
// HTTPClient allows injecting a custom *http.Client (optional).
HTTPClient *http.Client
}
Config holds the client configuration.
type ContentPart ¶
type ContentPart struct {
Type string `json:"type"`
Text *string `json:"text,omitempty"`
ImageURL *ImageURL `json:"image_url,omitempty"`
InputAudio *InputAudio `json:"input_audio,omitempty"`
}
ContentPart is one element of a multimodal message content array.
type CreateBatchParams ¶ added in v0.1.3
type CreateTemplateParams ¶
type CreateTemplateParams struct {
Name string `json:"name"`
Description *string `json:"description,omitempty"`
System *string `json:"system,omitempty"`
Messages []map[string]interface{} `json:"messages,omitempty"`
Model *string `json:"model,omitempty"`
Params map[string]interface{} `json:"params,omitempty"`
Variables []string `json:"variables,omitempty"`
}
CreateTemplateParams is the request body for POST /v1/templates.
type EmbeddingItem ¶ added in v0.1.3
type EmbeddingsParams ¶ added in v0.1.3
type EmbeddingsParams struct {
Model *string `json:"model,omitempty"`
Input interface{} `json:"input"`
Dimensions *int `json:"dimensions,omitempty"`
EncodingFormat *string `json:"encoding_format,omitempty"`
InputType *string `json:"input_type,omitempty"`
Provider interface{} `json:"provider,omitempty"`
User *string `json:"user,omitempty"`
}
type EmbeddingsResource ¶ added in v0.1.3
type EmbeddingsResource struct {
// contains filtered or unexported fields
}
func (*EmbeddingsResource) Create ¶ added in v0.1.3
func (r *EmbeddingsResource) Create(ctx context.Context, params EmbeddingsParams) (*EmbeddingsResponse, error)
type EmbeddingsResponse ¶ added in v0.1.3
type EmbeddingsResponse struct {
Object string `json:"object"`
Data []EmbeddingItem `json:"data"`
Model string `json:"model"`
Usage *EmbeddingsUsage `json:"usage,omitempty"`
}
type EmbeddingsUsage ¶ added in v0.1.3
type FileObject ¶ added in v0.1.3
type FileObject struct {
ID string `json:"id"`
Object *string `json:"object,omitempty"`
Bytes *int `json:"bytes,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty"`
Filename *string `json:"filename,omitempty"`
Purpose *string `json:"purpose,omitempty"`
Status *string `json:"status,omitempty"`
StatusDetails interface{} `json:"status_details,omitempty"`
}
type FilesResource ¶ added in v0.1.3
type FilesResource struct {
// contains filtered or unexported fields
}
func (*FilesResource) Delete ¶ added in v0.1.3
func (r *FilesResource) Delete(ctx context.Context, fileID string) error
func (*FilesResource) Get ¶ added in v0.1.3
func (r *FilesResource) Get(ctx context.Context, fileID string) (*FileObject, error)
func (*FilesResource) Upload ¶ added in v0.1.3
func (r *FilesResource) Upload(ctx context.Context, params UploadBatchFileParams) (*FileObject, error)
type ImageGenerationChunk ¶ added in v0.1.3
type ImageGenerationParams ¶ added in v0.1.3
type ImageGenerationParams struct {
Prompt string `json:"prompt"`
Model *string `json:"model,omitempty"`
N *int `json:"n,omitempty"`
Size *string `json:"size,omitempty"`
Quality *string `json:"quality,omitempty"`
ResponseFormat *string `json:"response_format,omitempty"`
OutputFormat *string `json:"output_format,omitempty"`
Stream *bool `json:"stream,omitempty"`
}
type ImageGenerationResponse ¶ added in v0.1.3
type ImageGenerationResponse struct {
Created int64 `json:"created"`
Data []ImageItem `json:"data"`
Background *string `json:"background,omitempty"`
OutputFormat *string `json:"output_format,omitempty"`
Quality *string `json:"quality,omitempty"`
Size *string `json:"size,omitempty"`
Usage *ImageUsage `json:"usage,omitempty"`
}
type ImageOptions ¶ added in v0.1.3
type ImageUsage ¶ added in v0.1.3
type ImageUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
InputTokensDetails map[string]interface{} `json:"input_tokens_details,omitempty"`
OutputTokensDetails map[string]interface{} `json:"output_tokens_details,omitempty"`
}
type ImagesResource ¶ added in v0.1.3
type ImagesResource struct {
// contains filtered or unexported fields
}
func (*ImagesResource) Generate ¶ added in v0.1.3
func (r *ImagesResource) Generate(ctx context.Context, params ImageGenerationParams) (*ImageGenerationResponse, error)
Generate sends a non-streaming image generation request and returns the full response.
func (*ImagesResource) Stream ¶ added in v0.1.3
func (r *ImagesResource) Stream(ctx context.Context, params ImageGenerationParams) (<-chan ImageGenerationChunk, <-chan error)
Stream opens a streaming image generation request. It returns two channels:
- chunkCh: receives parsed ImageGenerationChunks until [DONE] or error
- errCh: receives at most one error, then is closed
Both channels are always closed when the stream finishes. Callers must drain chunkCh before reading errCh, or use a select loop.
type InputAudio ¶ added in v0.1.3
type ListModelsParams ¶
type ListModelsParams struct {
Free *bool // nil = no filter
}
ListModelsParams holds optional query parameters for listing models.
type MeshAPIError ¶
type MeshAPIError struct {
// Status is the HTTP status code (0 for stream/parse errors).
Status int
// Code is the machine-readable error code slug (e.g. "unauthorized").
Code string
// RequestID is the req_<ULID> tracing identifier from the response.
RequestID string
// Message is the human-readable error description.
Message string
// Details contains validation error details (non-nil on 422 responses).
Details []interface{}
// ProviderError contains upstream provider error details when available.
ProviderError map[string]interface{}
// RetryAfterSeconds is set on 429 responses.
RetryAfterSeconds *int
}
MeshAPIError is returned when MeshAPI responds with a non-2xx status or sends an error frame mid-stream.
func (*MeshAPIError) Error ¶
func (e *MeshAPIError) Error() string
type ModelCompareResult ¶ added in v0.1.3
type ModelCompareResult struct {
Model string `json:"model"`
ResponseBody map[string]interface{} `json:"response_body,omitempty"`
Content *string `json:"content,omitempty"`
LatencyMs int `json:"latency_ms"`
Error *string `json:"error,omitempty"`
ErrorCode *string `json:"error_code,omitempty"`
Usage *TokenUsage `json:"usage,omitempty"`
RequestID string `json:"request_id"`
}
type ModelInfo ¶
type ModelInfo struct {
ID string `json:"id"`
Name string `json:"name"`
ContextLength *int `json:"context_length,omitempty"`
IsFree bool `json:"is_free"`
Pricing *ModelPricing `json:"pricing,omitempty"`
Description *string `json:"description,omitempty"`
SupportsThinking *bool `json:"supports_thinking,omitempty"`
SupportsCompletionsAPI *bool `json:"supports_completions_api,omitempty"`
SupportsResponsesAPI *bool `json:"supports_responses_api,omitempty"`
ModelType *string `json:"model_type,omitempty"`
InputModalities []string `json:"input_modalities,omitempty"`
OutputModalities []string `json:"output_modalities,omitempty"`
}
ModelInfo describes an available model.
type ModelOverride ¶ added in v0.1.3
type ModelPricing ¶
type ModelPricing struct {
PromptUSDPer1K *string `json:"prompt_usd_per_1k,omitempty"`
CompletionUSDPer1K *string `json:"completion_usd_per_1k,omitempty"`
ImageUSDPerImage *string `json:"image_usd_per_image,omitempty"`
DiscountPct *string `json:"discount_pct,omitempty"`
PromptUSDPer1KDiscounted *string `json:"prompt_usd_per_1k_discounted,omitempty"`
CompletionUSDPer1KDiscounted *string `json:"completion_usd_per_1k_discounted,omitempty"`
}
ModelPricing holds per-token pricing for a model.
type ModelsResource ¶
type ModelsResource struct {
// contains filtered or unexported fields
}
ModelsResource provides access to the /v1/models endpoints.
func (*ModelsResource) Free ¶
func (r *ModelsResource) Free(ctx context.Context) ([]ModelInfo, error)
Free returns only free-tier models.
func (*ModelsResource) List ¶
func (r *ModelsResource) List(ctx context.Context, params ListModelsParams) ([]ModelInfo, error)
List returns all available models. Pass a non-nil Free pointer to filter.
type ProviderPreferences ¶ added in v0.1.3
type ResponsesFunctionTool ¶ added in v0.1.3
type ResponsesParams ¶ added in v0.1.3
type ResponsesParams struct {
Model *string `json:"model,omitempty"`
Input interface{} `json:"input"`
Template *string `json:"template,omitempty"`
Variables map[string]string `json:"variables,omitempty"`
SessionID *string `json:"session_id,omitempty"`
Stream *bool `json:"stream,omitempty"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
Seed *int `json:"seed,omitempty"`
Reasoning map[string]interface{} `json:"reasoning,omitempty"`
Tools []interface{} `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
ResponseFormat map[string]interface{} `json:"response_format,omitempty"`
Plugins []interface{} `json:"plugins,omitempty"`
User *string `json:"user,omitempty"`
}
type ResponsesResource ¶ added in v0.1.3
type ResponsesResource struct {
// contains filtered or unexported fields
}
func (*ResponsesResource) Create ¶ added in v0.1.3
func (r *ResponsesResource) Create(ctx context.Context, params ResponsesParams) (*ResponsesResponse, error)
func (*ResponsesResource) Stream ¶ added in v0.1.3
func (r *ResponsesResource) Stream(ctx context.Context, params ResponsesParams) (<-chan ResponsesStreamEvent, <-chan error)
type ResponsesResponse ¶ added in v0.1.3
type ResponsesResponse struct {
ID *string `json:"id,omitempty"`
Object *string `json:"object,omitempty"`
Model *string `json:"model,omitempty"`
Output []interface{} `json:"output,omitempty"`
Usage *ResponsesUsage `json:"usage,omitempty"`
Status *string `json:"status,omitempty"`
Extra map[string]interface{} `json:"-"`
}
type ResponsesStreamEvent ¶ added in v0.1.3
type ResponsesStreamEvent map[string]interface{}
type ResponsesUsage ¶ added in v0.1.3
type ResponsesUsage struct {
InputTokens *int `json:"input_tokens,omitempty"`
OutputTokens *int `json:"output_tokens,omitempty"`
TotalTokens *int `json:"total_tokens,omitempty"`
PromptTokens *int `json:"prompt_tokens,omitempty"`
CompletionTokens *int `json:"completion_tokens,omitempty"`
PromptTokensDetails map[string]interface{} `json:"prompt_tokens_details,omitempty"`
CompletionTokensDetails map[string]interface{} `json:"completion_tokens_details,omitempty"`
ClassifierTokens *int `json:"classifier_tokens,omitempty"`
}
type TemplateSummary ¶
type TemplateSummary struct {
ID string `json:"id"`
Name string `json:"name"`
Owner *string `json:"owner"`
IsGlobal bool `json:"is_global"`
Description *string `json:"description,omitempty"`
System *string `json:"system,omitempty"`
Messages []map[string]interface{} `json:"messages,omitempty"`
Model *string `json:"model,omitempty"`
Params map[string]interface{} `json:"params,omitempty"`
Variables []string `json:"variables,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
TemplateSummary is the response shape for all template operations.
type TemplatesResource ¶
type TemplatesResource struct {
// contains filtered or unexported fields
}
TemplatesResource provides access to the /v1/templates CRUD endpoints.
func (*TemplatesResource) Create ¶
func (r *TemplatesResource) Create(ctx context.Context, params CreateTemplateParams) (*TemplateSummary, error)
Create creates a new prompt template.
func (*TemplatesResource) Delete ¶
func (r *TemplatesResource) Delete(ctx context.Context, id string) error
Delete deletes a template (returns nil on 204 No Content).
func (*TemplatesResource) Get ¶
func (r *TemplatesResource) Get(ctx context.Context, id string) (*TemplateSummary, error)
Get returns a single template by ID.
func (*TemplatesResource) List ¶
func (r *TemplatesResource) List(ctx context.Context) ([]TemplateSummary, error)
List returns all templates owned by the authenticated user.
func (*TemplatesResource) Update ¶
func (r *TemplatesResource) Update(ctx context.Context, id string, params UpdateTemplateParams) (*TemplateSummary, error)
Update partially updates a template.
type TokenUsage ¶ added in v0.1.3
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
Tool defines a callable function available to the model.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolCallFunction `json:"function"`
}
ToolCall represents a tool invocation in an assistant message.
type ToolCallFunction ¶
ToolCallFunction holds the name and JSON-encoded arguments for a tool call.
type ToolChoice ¶
type ToolChoice interface{}
ToolChoice controls model tool use. Use "auto", "none", "required", or ToolChoiceObject.
type ToolChoiceFunction ¶
type ToolChoiceFunction struct {
Name string `json:"name"`
}
ToolChoiceFunction names the function to call.
type ToolChoiceObject ¶
type ToolChoiceObject struct {
Type string `json:"type"`
Function ToolChoiceFunction `json:"function"`
}
ToolChoiceObject selects a specific function.
type ToolFunction ¶
type ToolFunction struct {
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Parameters interface{} `json:"parameters,omitempty"`
}
ToolFunction describes a callable function.
type UpdateTemplateParams ¶
type UpdateTemplateParams struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
System *string `json:"system,omitempty"`
Messages []map[string]interface{} `json:"messages,omitempty"`
Model *string `json:"model,omitempty"`
Params map[string]interface{} `json:"params,omitempty"`
Variables []string `json:"variables,omitempty"`
}
UpdateTemplateParams is the request body for PATCH /v1/templates/{id}.
type UploadBatchFileParams ¶ added in v0.1.3
type UploadBatchFileParams struct {
Purpose string `json:"purpose,omitempty"`
Requests []BatchRequestItem `json:"requests"`
}
type UsageInfo ¶
type UsageInfo struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptTokensDetails map[string]interface{} `json:"prompt_tokens_details,omitempty"`
CompletionTokensDetails map[string]interface{} `json:"completion_tokens_details,omitempty"`
ClassifierPromptTokens *int `json:"classifier_prompt_tokens,omitempty"`
ClassifierCompletionTokens *int `json:"classifier_completion_tokens,omitempty"`
ClassifierTokens *int `json:"classifier_tokens,omitempty"`
}
UsageInfo holds token counts for a completion.