Documentation
¶
Overview ¶
Package aiozai provides a Go client SDK for the AIOZ AI API.
The SDK is auto-generated from the OpenAPI specification and provides typed access to all 218+ API endpoints with 578+ model definitions.
Quick Start ¶
client, err := aiozai.NewClient(
aiozai.WithAPIKey(os.Getenv("AIOZ_AI_API_KEY")),
)
if err != nil {
log.Fatal(err)
}
Features ¶
- Full type safety for all API endpoints and models
- API Key configured once at client creation
- Automatic retry with exponential backoff for transient failures
- Configurable timeouts for standard and upload operations
- Domain-grouped service access (Models, Datasets, Competitions, etc.)
Authentication ¶
The SDK uses API Key. Set your API key when creating the client with WithAPIKey(). All api-key/* endpoints automatically include the x-api-key header. Public endpoints (public/*) do not require authentication.
Error Handling ¶
API errors are returned as *AiozAPIError which implements the error interface. Use errors.As() to check for API-specific errors:
var apiErr *aiozai.AiozAPIError
if errors.As(err, &apiErr) {
log.Printf("API error %d: %s", apiErr.StatusCode, apiErr.Message)
}
Index ¶
- Constants
- Variables
- type AiozAPIError
- type Client
- func (c *Client) Collections() *services.CollectionsService
- func (c *Client) Competitions() *services.CompetitionsService
- func (c *Client) Config() *ClientConfig
- func (c *Client) Core() *services.CoreService
- func (c *Client) Datasets() *services.DatasetsService
- func (c *Client) Discussions() *services.DiscussionsService
- func (c *Client) Models() *services.ModelsService
- func (c *Client) Notifications() *services.NotificationsService
- func (c *Client) Organizations() *services.OrganizationsService
- func (c *Client) Public() *services.PublicService
- func (c *Client) Raw() *apiclient.AiozaiPlatform
- func (c *Client) Repositories() *services.RepositoriesService
- func (c *Client) Storage() *services.StorageService
- func (c *Client) Users() *services.UsersService
- type ClientConfig
- type Option
- type RetryConfig
Constants ¶
const ( // DefaultBaseURL is the default base URL for the AIOZ AI API. DefaultBaseURL = "https://api.aiozai.network/api/v1" // DefaultTimeout is the default request timeout. DefaultTimeout = 30 * time.Second // DefaultUploadTimeout is the default timeout for upload operations. DefaultUploadTimeout = 300 * time.Second // DefaultMaxRetries is the default number of retry attempts. DefaultMaxRetries = 3 // DefaultBaseDelay is the initial delay for exponential backoff. DefaultBaseDelay = 1 * time.Second // DefaultMaxDelay is the maximum delay between retries. DefaultMaxDelay = 30 * time.Second )
Variables ¶
var RetryableStatusCodes = []int{500, 502, 503, 504}
RetryableStatusCodes contains HTTP status codes that trigger a retry.
Functions ¶
This section is empty.
Types ¶
type AiozAPIError ¶
type AiozAPIError struct {
StatusCode int `json:"statusCode"`
ErrorCode string `json:"errorCode"`
Message string `json:"message"`
Endpoint string `json:"endpoint"`
Method string `json:"method"`
RequestID string `json:"requestId,omitempty"`
}
AiozAPIError represents a structured error from the AIOZ AI API.
func NewAPIError ¶
func NewAPIError(statusCode int, errorCode, message, endpoint, method, requestID string) *AiozAPIError
NewAPIError creates a new AiozAPIError.
func (*AiozAPIError) Error ¶
func (e *AiozAPIError) Error() string
Error implements the error interface.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the AIOZ AI SDK client.
func (*Client) Collections ¶
func (c *Client) Collections() *services.CollectionsService
Collections returns the collections service for curated collection operations.
func (*Client) Competitions ¶
func (c *Client) Competitions() *services.CompetitionsService
Competitions returns the competitions service for competition operations.
func (*Client) Config ¶
func (c *Client) Config() *ClientConfig
Config returns the resolved client configuration.
func (*Client) Core ¶
func (c *Client) Core() *services.CoreService
Core returns the core service for root endpoints and minor services.
func (*Client) Datasets ¶
func (c *Client) Datasets() *services.DatasetsService
Datasets returns the datasets service for dataset management operations.
func (*Client) Discussions ¶
func (c *Client) Discussions() *services.DiscussionsService
Discussions returns the discussions service for discussion and comment operations.
func (*Client) Models ¶
func (c *Client) Models() *services.ModelsService
Models returns the models service for AI model management operations.
func (*Client) Notifications ¶
func (c *Client) Notifications() *services.NotificationsService
Notifications returns the notifications service.
func (*Client) Organizations ¶
func (c *Client) Organizations() *services.OrganizationsService
Organizations returns the organizations service for org management operations.
func (*Client) Public ¶
func (c *Client) Public() *services.PublicService
Public returns the public service for unauthenticated endpoints.
func (*Client) Raw ¶
func (c *Client) Raw() *apiclient.AiozaiPlatform
Raw returns the underlying go-swagger generated client for direct access.
func (*Client) Repositories ¶
func (c *Client) Repositories() *services.RepositoriesService
Repositories returns the repositories service for repository operations.
func (*Client) Storage ¶
func (c *Client) Storage() *services.StorageService
Storage returns the storage service for upload and storage operations.
func (*Client) Users ¶
func (c *Client) Users() *services.UsersService
Users returns the users service for user management operations.
type ClientConfig ¶
type ClientConfig struct {
APIKey string
BaseURL string
Timeout time.Duration
UploadTimeout time.Duration
RetryConfig *RetryConfig
HTTPClient *http.Client
}
ClientConfig holds the resolved configuration for the SDK client.
type Option ¶
type Option func(*ClientConfig)
Option is a functional option for configuring the SDK client.
func WithAPIKey ¶
WithAPIKey sets the API key for authenticated endpoints.
func WithBaseURL ¶
WithBaseURL overrides the default API base URL.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client for the SDK.
func WithRetryConfig ¶
func WithRetryConfig(rc *RetryConfig) Option
WithRetryConfig overrides the default retry configuration.
func WithTimeout ¶
WithTimeout sets the request timeout for standard API calls.
func WithUploadTimeout ¶
WithUploadTimeout sets the timeout for upload operations.