swarms

package module
v0.1.0-alpha.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

Swarms Client Go API Library

Go Reference

The Swarms Client Go library provides convenient access to the Swarms Client REST API from applications written in Go.

It is generated with Stainless.

MCP Server

Use the Swarms Client MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

Add to Cursor Install in VS Code

Note: You may need to set environment variables in your MCP client.

Installation

import (
	"github.com/The-Swarm-Corporation/swarms-client-go" // imported as swarms
)

Or to pin the version:

go get -u 'github.com/The-Swarm-Corporation/[email protected]'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/The-Swarm-Corporation/swarms-client-go"
	"github.com/The-Swarm-Corporation/swarms-client-go/option"
)

func main() {
	client := swarms.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("SWARMS_API_KEY")
	)
	response, err := client.GetRoot(context.TODO())
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response)
}

Request fields

The swarms library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, swarms.String(string), swarms.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := swarms.ExampleParams{
	ID:   "id_xxx",             // required property
	Name: swarms.String("..."), // optional property

	Point: swarms.Point{
		X: 0,             // required field will serialize as 0
		Y: swarms.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: swarms.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[swarms.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := swarms.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.GetRoot(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *swarms.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.GetRoot(context.TODO())
if err != nil {
	var apierr *swarms.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.GetRoot(
	ctx,
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper swarms.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := swarms.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.GetRoot(context.TODO(), option.WithMaxRetries(5))
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
response, err := client.GetRoot(context.TODO(), option.WithResponseInto(&response))
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", response)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: swarms.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := swarms.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (SWARMS_API_KEY, SWARMS_CLIENT_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type AgentBatchRunParams

type AgentBatchRunParams struct {
	Body []AgentCompletionParam
	// contains filtered or unexported fields
}

func (AgentBatchRunParams) MarshalJSON

func (r AgentBatchRunParams) MarshalJSON() (data []byte, err error)

func (*AgentBatchRunParams) UnmarshalJSON

func (r *AgentBatchRunParams) UnmarshalJSON(data []byte) error

type AgentBatchRunResponse

type AgentBatchRunResponse struct {
	// The unique identifier for the agent batch completion.
	BatchID string `json:"batch_id" api:"nullable"`
	// The execution time of the agent batch completion.
	ExecutionTime float64 `json:"execution_time" api:"nullable"`
	// The outputs generated by the agent.
	Results any `json:"results"`
	// The timestamp when the agent batch completion was created.
	Timestamp string `json:"timestamp" api:"nullable"`
	// The total number of requests in the batch.
	TotalRequests int64 `json:"total_requests" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BatchID       respjson.Field
		ExecutionTime respjson.Field
		Results       respjson.Field
		Timestamp     respjson.Field
		TotalRequests respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AgentBatchRunResponse) RawJSON

func (r AgentBatchRunResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AgentBatchRunResponse) UnmarshalJSON

func (r *AgentBatchRunResponse) UnmarshalJSON(data []byte) error

type AgentBatchService

type AgentBatchService struct {
	Options []option.RequestOption
}

AgentBatchService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAgentBatchService method instead.

func NewAgentBatchService

func NewAgentBatchService(opts ...option.RequestOption) (r AgentBatchService)

NewAgentBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AgentBatchService) Run

Run a batch of agents with the specified tasks using a thread pool.

type AgentCompletionHistoryUnionParam

type AgentCompletionHistoryUnionParam struct {
	OfAnyMap         map[string]any      `json:",omitzero,inline"`
	OfMapOfStringMap []map[string]string `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (AgentCompletionHistoryUnionParam) MarshalJSON

func (u AgentCompletionHistoryUnionParam) MarshalJSON() ([]byte, error)

func (*AgentCompletionHistoryUnionParam) UnmarshalJSON

func (u *AgentCompletionHistoryUnionParam) UnmarshalJSON(data []byte) error

type AgentCompletionParam

type AgentCompletionParam struct {
	// An optional image URL that may be associated with the agent's task or
	// representation.
	Img param.Opt[string] `json:"img,omitzero"`
	// The task to be completed by the agent.
	Task param.Opt[string] `json:"task,omitzero"`
	// The history of the agent's previous tasks and responses. Can be either a
	// dictionary or a list of message objects.
	History AgentCompletionHistoryUnionParam `json:"history,omitzero"`
	// A list of image URLs that may be associated with the agent's task or
	// representation.
	Imgs []string `json:"imgs,omitzero"`
	// A list of tools that the agent should use to complete its task.
	ToolsEnabled []string `json:"tools_enabled,omitzero"`
	// The configuration of the agent to be completed.
	AgentConfig AgentSpecParam `json:"agent_config,omitzero"`
	// contains filtered or unexported fields
}

func (AgentCompletionParam) MarshalJSON

func (r AgentCompletionParam) MarshalJSON() (data []byte, err error)

func (*AgentCompletionParam) UnmarshalJSON

func (r *AgentCompletionParam) UnmarshalJSON(data []byte) error

type AgentListResponse

type AgentListResponse map[string]any

type AgentRunParams

type AgentRunParams struct {
	AgentCompletion AgentCompletionParam
	// contains filtered or unexported fields
}

func (AgentRunParams) MarshalJSON

func (r AgentRunParams) MarshalJSON() (data []byte, err error)

func (*AgentRunParams) UnmarshalJSON

func (r *AgentRunParams) UnmarshalJSON(data []byte) error

type AgentRunResponse

type AgentRunResponse struct {
	// A description of the agent or completion.
	Description string `json:"description" api:"nullable"`
	// The unique identifier for the agent completion.
	JobID string `json:"job_id" api:"nullable"`
	// The name of the agent.
	Name string `json:"name" api:"nullable"`
	// The outputs generated by the agent.
	Outputs any `json:"outputs"`
	// Indicates whether the agent completion was successful.
	Success bool `json:"success" api:"nullable"`
	// The temperature setting used for the agent's response generation.
	Temperature float64 `json:"temperature" api:"nullable"`
	// The timestamp when the agent completion was created.
	Timestamp string `json:"timestamp" api:"nullable"`
	// Usage statistics or metadata for the agent completion.
	Usage map[string]any `json:"usage" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		JobID       respjson.Field
		Name        respjson.Field
		Outputs     respjson.Field
		Success     respjson.Field
		Temperature respjson.Field
		Timestamp   respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AgentRunResponse) RawJSON

func (r AgentRunResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AgentRunResponse) UnmarshalJSON

func (r *AgentRunResponse) UnmarshalJSON(data []byte) error

type AgentService

type AgentService struct {
	Options []option.RequestOption
	Batch   AgentBatchService
}

AgentService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAgentService method instead.

func NewAgentService

func NewAgentService(opts ...option.RequestOption) (r AgentService)

NewAgentService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AgentService) List

func (r *AgentService) List(ctx context.Context, opts ...option.RequestOption) (res *AgentListResponse, err error)

Get all unique agent configurations that the user has created or used, without task details. Allows users to reuse agent configs with new tasks.

func (*AgentService) Run

func (r *AgentService) Run(ctx context.Context, body AgentRunParams, opts ...option.RequestOption) (res *AgentRunResponse, err error)

Run an agent with the specified task. Supports streaming when stream=True.

type AgentSpecMcpConfigsParam

type AgentSpecMcpConfigsParam struct {
	// List of MCP connections
	Connections []McpConnectionParam `json:"connections,omitzero" api:"required"`
	// contains filtered or unexported fields
}

The MCP connections to use for the agent. This is a list of MCP connections. Includes multiple MCP connections.

The property Connections is required.

func (AgentSpecMcpConfigsParam) MarshalJSON

func (r AgentSpecMcpConfigsParam) MarshalJSON() (data []byte, err error)

func (*AgentSpecMcpConfigsParam) UnmarshalJSON

func (r *AgentSpecMcpConfigsParam) UnmarshalJSON(data []byte) error

type AgentSpecParam

type AgentSpecParam struct {
	// The unique name assigned to the agent, which identifies its role and
	// functionality within the swarm.
	AgentName param.Opt[string] `json:"agent_name,omitzero" api:"required"`
	// A flag indicating whether the agent should automatically create prompts based on
	// the task requirements.
	AutoGeneratePrompt param.Opt[bool] `json:"auto_generate_prompt,omitzero"`
	// A detailed explanation of the agent's purpose, capabilities, and any specific
	// tasks it is designed to perform.
	Description param.Opt[string] `json:"description,omitzero"`
	// A flag indicating whether the agent should dynamically adjust its temperature
	// based on the task.
	DynamicTemperatureEnabled param.Opt[bool] `json:"dynamic_temperature_enabled,omitzero"`
	// The maximum number of times the agent is allowed to repeat its task, enabling
	// iterative processing if necessary.
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// The maximum number of tokens that the agent is allowed to generate in its
	// responses, limiting output length.
	MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"`
	// The URL of the MCP server that the agent can use to complete its task.
	McpURL param.Opt[string] `json:"mcp_url,omitzero"`
	// The name of the AI model that the agent will utilize for processing tasks and
	// generating outputs. For example: gpt-4o, gpt-4o-mini, openai/o3-mini
	ModelName param.Opt[string] `json:"model_name,omitzero"`
	// The effort to put into reasoning.
	ReasoningEffort param.Opt[string] `json:"reasoning_effort,omitzero"`
	// A parameter enabling an agent to use reasoning.
	ReasoningEnabled param.Opt[bool] `json:"reasoning_enabled,omitzero"`
	// The designated role of the agent within the swarm, which influences its behavior
	// and interaction with other agents.
	Role param.Opt[string] `json:"role,omitzero"`
	// A flag indicating whether the agent should stream its output.
	StreamingOn param.Opt[bool] `json:"streaming_on,omitzero"`
	// The initial instruction or context provided to the agent, guiding its behavior
	// and responses during execution.
	SystemPrompt param.Opt[string] `json:"system_prompt,omitzero"`
	// A parameter that controls the randomness of the agent's output; lower values
	// result in more deterministic responses.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// The number of tokens to use for thinking.
	ThinkingTokens param.Opt[int64] `json:"thinking_tokens,omitzero"`
	// A parameter enabling an agent to summarize tool calls.
	ToolCallSummary param.Opt[bool] `json:"tool_call_summary,omitzero"`
	// Additional arguments to pass to the LLM such as top_p, frequency_penalty,
	// presence_penalty, etc.
	LlmArgs map[string]any `json:"llm_args,omitzero"`
	// The MCP connections to use for the agent. This is a list of MCP connections.
	// Includes multiple MCP connections.
	McpConfigs AgentSpecMcpConfigsParam `json:"mcp_configs,omitzero"`
	// A dictionary of tools that the agent can use to complete its task.
	ToolsListDictionary []map[string]any `json:"tools_list_dictionary,omitzero"`
	// The MCP connection to use for the agent.
	McpConfig McpConnectionParam `json:"mcp_config,omitzero"`
	// contains filtered or unexported fields
}

The property AgentName is required.

func (AgentSpecParam) MarshalJSON

func (r AgentSpecParam) MarshalJSON() (data []byte, err error)

func (*AgentSpecParam) UnmarshalJSON

func (r *AgentSpecParam) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	Options         []option.RequestOption
	Health          HealthService
	Agent           AgentService
	Models          ModelService
	Swarms          SwarmService
	ReasoningAgents ReasoningAgentService
	Client          ClientService
}

Client creates a struct with services and top level methods that help with interacting with the swarms-client API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (SWARMS_API_KEY, SWARMS_CLIENT_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) GetRoot

func (r *Client) GetRoot(ctx context.Context, opts ...option.RequestOption) (res *GetRootResponse, err error)

Root

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type ClientAdvancedResearchBatchNewCompletionParams

type ClientAdvancedResearchBatchNewCompletionParams struct {
	// The input schemas for the advanced research
	InputSchemas []ClientAdvancedResearchBatchNewCompletionParamsInputSchema `json:"input_schemas,omitzero" api:"required"`
	// contains filtered or unexported fields
}

func (ClientAdvancedResearchBatchNewCompletionParams) MarshalJSON

func (r ClientAdvancedResearchBatchNewCompletionParams) MarshalJSON() (data []byte, err error)

func (*ClientAdvancedResearchBatchNewCompletionParams) UnmarshalJSON

type ClientAdvancedResearchBatchNewCompletionParamsInputSchema

type ClientAdvancedResearchBatchNewCompletionParamsInputSchema struct {
	// The task to be completed
	Task param.Opt[string] `json:"task,omitzero" api:"required"`
	// The configuration for the advanced research
	Config ClientAdvancedResearchBatchNewCompletionParamsInputSchemaConfig `json:"config,omitzero" api:"required"`
	// The image to be used for the advanced research
	Img param.Opt[string] `json:"img,omitzero"`
	// contains filtered or unexported fields
}

The properties Config, Task are required.

func (ClientAdvancedResearchBatchNewCompletionParamsInputSchema) MarshalJSON

func (*ClientAdvancedResearchBatchNewCompletionParamsInputSchema) UnmarshalJSON

type ClientAdvancedResearchBatchNewCompletionParamsInputSchemaConfig

type ClientAdvancedResearchBatchNewCompletionParamsInputSchemaConfig struct {
	// Description of the advanced research session
	Description param.Opt[string] `json:"description,omitzero"`
	// Name of the director agent
	DirectorAgentName param.Opt[string] `json:"director_agent_name,omitzero"`
	// Maximum loops for the director agent
	DirectorMaxLoops param.Opt[int64] `json:"director_max_loops,omitzero"`
	// Maximum tokens for the director agent's output
	DirectorMaxTokens param.Opt[int64] `json:"director_max_tokens,omitzero"`
	// Model name for the director agent
	DirectorModelName param.Opt[string] `json:"director_model_name,omitzero"`
	// Maximum characters to return from the Exa search tool
	ExaSearchMaxCharacters param.Opt[int64] `json:"exa_search_max_characters,omitzero"`
	// Number of results to return from the Exa search tool
	ExaSearchNumResults param.Opt[int64] `json:"exa_search_num_results,omitzero"`
	// Number of research loops to run
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// Name of the advanced research session
	Name param.Opt[string] `json:"name,omitzero"`
	// Model name for worker agents
	WorkerModelName param.Opt[string] `json:"worker_model_name,omitzero"`
	// contains filtered or unexported fields
}

The configuration for the advanced research

func (ClientAdvancedResearchBatchNewCompletionParamsInputSchemaConfig) MarshalJSON

func (*ClientAdvancedResearchBatchNewCompletionParamsInputSchemaConfig) UnmarshalJSON

type ClientAdvancedResearchBatchNewCompletionResponse

type ClientAdvancedResearchBatchNewCompletionResponse struct {
	// The id of the advanced research session
	ID string `json:"id" api:"required"`
	// The number of characters per source used for the advanced research session
	CharactersPerSource int64 `json:"characters_per_source" api:"required"`
	// The description of the advanced research session
	Description string `json:"description" api:"required"`
	// The name of the advanced research session
	Name string `json:"name" api:"required"`
	// The outputs of the advanced research session
	Outputs any `json:"outputs" api:"required"`
	// The number of sources used for the advanced research session
	Sources int64 `json:"sources" api:"required"`
	// The timestamp of the advanced research session
	Timestamp string `json:"timestamp" api:"required"`
	// The usage of the advanced research session
	Usage map[string]any `json:"usage" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                  respjson.Field
		CharactersPerSource respjson.Field
		Description         respjson.Field
		Name                respjson.Field
		Outputs             respjson.Field
		Sources             respjson.Field
		Timestamp           respjson.Field
		Usage               respjson.Field
		ExtraFields         map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ClientAdvancedResearchBatchNewCompletionResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientAdvancedResearchBatchNewCompletionResponse) UnmarshalJSON

type ClientAdvancedResearchBatchService

type ClientAdvancedResearchBatchService struct {
	Options []option.RequestOption
}

ClientAdvancedResearchBatchService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientAdvancedResearchBatchService method instead.

func NewClientAdvancedResearchBatchService

func NewClientAdvancedResearchBatchService(opts ...option.RequestOption) (r ClientAdvancedResearchBatchService)

NewClientAdvancedResearchBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientAdvancedResearchBatchService) NewCompletion

Execute multiple advanced research sessions concurrently with independent configurations for high-throughput research workflows.

type ClientAdvancedResearchNewCompletionParams

type ClientAdvancedResearchNewCompletionParams struct {
	// The task to be completed
	Task param.Opt[string] `json:"task,omitzero" api:"required"`
	// The configuration for the advanced research
	Config ClientAdvancedResearchNewCompletionParamsConfig `json:"config,omitzero" api:"required"`
	// The image to be used for the advanced research
	Img param.Opt[string] `json:"img,omitzero"`
	// contains filtered or unexported fields
}

func (ClientAdvancedResearchNewCompletionParams) MarshalJSON

func (r ClientAdvancedResearchNewCompletionParams) MarshalJSON() (data []byte, err error)

func (*ClientAdvancedResearchNewCompletionParams) UnmarshalJSON

func (r *ClientAdvancedResearchNewCompletionParams) UnmarshalJSON(data []byte) error

type ClientAdvancedResearchNewCompletionParamsConfig

type ClientAdvancedResearchNewCompletionParamsConfig struct {
	// Description of the advanced research session
	Description param.Opt[string] `json:"description,omitzero"`
	// Name of the director agent
	DirectorAgentName param.Opt[string] `json:"director_agent_name,omitzero"`
	// Maximum loops for the director agent
	DirectorMaxLoops param.Opt[int64] `json:"director_max_loops,omitzero"`
	// Maximum tokens for the director agent's output
	DirectorMaxTokens param.Opt[int64] `json:"director_max_tokens,omitzero"`
	// Model name for the director agent
	DirectorModelName param.Opt[string] `json:"director_model_name,omitzero"`
	// Maximum characters to return from the Exa search tool
	ExaSearchMaxCharacters param.Opt[int64] `json:"exa_search_max_characters,omitzero"`
	// Number of results to return from the Exa search tool
	ExaSearchNumResults param.Opt[int64] `json:"exa_search_num_results,omitzero"`
	// Number of research loops to run
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// Name of the advanced research session
	Name param.Opt[string] `json:"name,omitzero"`
	// Model name for worker agents
	WorkerModelName param.Opt[string] `json:"worker_model_name,omitzero"`
	// contains filtered or unexported fields
}

The configuration for the advanced research

func (ClientAdvancedResearchNewCompletionParamsConfig) MarshalJSON

func (r ClientAdvancedResearchNewCompletionParamsConfig) MarshalJSON() (data []byte, err error)

func (*ClientAdvancedResearchNewCompletionParamsConfig) UnmarshalJSON

type ClientAdvancedResearchNewCompletionResponse

type ClientAdvancedResearchNewCompletionResponse struct {
	// The id of the advanced research session
	ID string `json:"id" api:"required"`
	// The number of characters per source used for the advanced research session
	CharactersPerSource int64 `json:"characters_per_source" api:"required"`
	// The description of the advanced research session
	Description string `json:"description" api:"required"`
	// The name of the advanced research session
	Name string `json:"name" api:"required"`
	// The outputs of the advanced research session
	Outputs any `json:"outputs" api:"required"`
	// The number of sources used for the advanced research session
	Sources int64 `json:"sources" api:"required"`
	// The timestamp of the advanced research session
	Timestamp string `json:"timestamp" api:"required"`
	// The usage of the advanced research session
	Usage map[string]any `json:"usage" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                  respjson.Field
		CharactersPerSource respjson.Field
		Description         respjson.Field
		Name                respjson.Field
		Outputs             respjson.Field
		Sources             respjson.Field
		Timestamp           respjson.Field
		Usage               respjson.Field
		ExtraFields         map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ClientAdvancedResearchNewCompletionResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientAdvancedResearchNewCompletionResponse) UnmarshalJSON

func (r *ClientAdvancedResearchNewCompletionResponse) UnmarshalJSON(data []byte) error

type ClientAdvancedResearchService

type ClientAdvancedResearchService struct {
	Options []option.RequestOption
	Batch   ClientAdvancedResearchBatchService
}

ClientAdvancedResearchService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientAdvancedResearchService method instead.

func NewClientAdvancedResearchService

func NewClientAdvancedResearchService(opts ...option.RequestOption) (r ClientAdvancedResearchService)

NewClientAdvancedResearchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientAdvancedResearchService) NewCompletion

Execute comprehensive research sessions with multi-source data collection, analysis, and synthesis capabilities.

type ClientAutoSwarmBuilderNewCompletionParams

type ClientAutoSwarmBuilderNewCompletionParams struct {
	// A description of the swarm.
	Description param.Opt[string] `json:"description,omitzero"`
	// Maximum number of loops to run.
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// The maximum number of tokens to use for the swarm.
	MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"`
	// The model name to use for the swarm.
	ModelName param.Opt[string] `json:"model_name,omitzero"`
	// The name of the swarm.
	Name param.Opt[string] `json:"name,omitzero"`
	// The task for the swarm, if any.
	Task param.Opt[string] `json:"task,omitzero"`
	// The type of execution to perform.
	//
	// Any of "return-agents", "return-swarm-router-config", "return-agents-objects".
	ExecutionType ClientAutoSwarmBuilderNewCompletionParamsExecutionType `json:"execution_type,omitzero"`
	// contains filtered or unexported fields
}

func (ClientAutoSwarmBuilderNewCompletionParams) MarshalJSON

func (r ClientAutoSwarmBuilderNewCompletionParams) MarshalJSON() (data []byte, err error)

func (*ClientAutoSwarmBuilderNewCompletionParams) UnmarshalJSON

func (r *ClientAutoSwarmBuilderNewCompletionParams) UnmarshalJSON(data []byte) error

type ClientAutoSwarmBuilderNewCompletionParamsExecutionType

type ClientAutoSwarmBuilderNewCompletionParamsExecutionType string

The type of execution to perform.

const (
	ClientAutoSwarmBuilderNewCompletionParamsExecutionTypeReturnAgents            ClientAutoSwarmBuilderNewCompletionParamsExecutionType = "return-agents"
	ClientAutoSwarmBuilderNewCompletionParamsExecutionTypeReturnSwarmRouterConfig ClientAutoSwarmBuilderNewCompletionParamsExecutionType = "return-swarm-router-config"
	ClientAutoSwarmBuilderNewCompletionParamsExecutionTypeReturnAgentsObjects     ClientAutoSwarmBuilderNewCompletionParamsExecutionType = "return-agents-objects"
)

type ClientAutoSwarmBuilderNewCompletionResponse

type ClientAutoSwarmBuilderNewCompletionResponse struct {
	// Whether the swarm was built successfully.
	Success bool `json:"success" api:"required"`
	// The job ID of the swarm.
	JobID string `json:"job_id" api:"nullable"`
	// The outputs of the auto swarms builder.
	Outputs map[string]any `json:"outputs" api:"nullable"`
	// The timestamp of the swarm execution.
	Timestamp string `json:"timestamp" api:"nullable"`
	// The type of the swarm execution.
	Type string `json:"type" api:"nullable"`
	// The usage of the swarm execution.
	Usage map[string]any `json:"usage" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Success     respjson.Field
		JobID       respjson.Field
		Outputs     respjson.Field
		Timestamp   respjson.Field
		Type        respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Schema for the Auto Swarm Builder API response.

Attributes: success (bool): Whether the swarm was built successfully. job_id (Optional[str]): The job ID of the swarm. outputs (Optional[dict]): The outputs of the auto swarms builder. type (Optional[str]): The type of the swarm execution. timestamp (Optional[str]): The timestamp of the swarm execution. usage (Optional[dict]): The usage statistics of the swarm execution.

func (ClientAutoSwarmBuilderNewCompletionResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientAutoSwarmBuilderNewCompletionResponse) UnmarshalJSON

func (r *ClientAutoSwarmBuilderNewCompletionResponse) UnmarshalJSON(data []byte) error

type ClientAutoSwarmBuilderService

type ClientAutoSwarmBuilderService struct {
	Options []option.RequestOption
}

ClientAutoSwarmBuilderService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientAutoSwarmBuilderService method instead.

func NewClientAutoSwarmBuilderService

func NewClientAutoSwarmBuilderService(opts ...option.RequestOption) (r ClientAutoSwarmBuilderService)

NewClientAutoSwarmBuilderService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientAutoSwarmBuilderService) ListExecutionTypes

func (r *ClientAutoSwarmBuilderService) ListExecutionTypes(ctx context.Context, opts ...option.RequestOption) (res *[]string, err error)

Retrieve all available execution types and return formats for the Auto Swarm Builder endpoint.

func (*ClientAutoSwarmBuilderService) NewCompletion

Generate and orchestrate agent swarms autonomously using AI-powered swarm composition and task decomposition.

type ClientBatchedGridWorkflowCompleteWorkflowParams

type ClientBatchedGridWorkflowCompleteWorkflowParams struct {
	// The description of the batched grid workflow.
	Description param.Opt[string] `json:"description,omitzero"`
	// The maximum number of loops to be completed by the batched grid workflow.
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// The name of the batched grid workflow.
	Name param.Opt[string] `json:"name,omitzero"`
	// The agent completions to be completed by the batched grid workflow.
	AgentCompletions []AgentSpecParam `json:"agent_completions,omitzero"`
	// The images to be used by the batched grid workflow.
	Imgs []string `json:"imgs,omitzero"`
	// The tasks to be completed by the batched grid workflow.
	Tasks []string `json:"tasks,omitzero"`
	// contains filtered or unexported fields
}

func (ClientBatchedGridWorkflowCompleteWorkflowParams) MarshalJSON

func (r ClientBatchedGridWorkflowCompleteWorkflowParams) MarshalJSON() (data []byte, err error)

func (*ClientBatchedGridWorkflowCompleteWorkflowParams) UnmarshalJSON

type ClientBatchedGridWorkflowCompleteWorkflowResponse

type ClientBatchedGridWorkflowCompleteWorkflowResponse struct {
	// The description of the batched grid workflow.
	Description string `json:"description" api:"required"`
	// The job ID of the batched grid workflow.
	JobID string `json:"job_id" api:"required"`
	// The name of the batched grid workflow.
	Name string `json:"name" api:"required"`
	// The outputs of the batched grid workflow.
	Outputs any `json:"outputs" api:"required"`
	// The status of the batched grid workflow.
	Status string `json:"status" api:"required"`
	// The timestamp of the batched grid workflow.
	Timestamp string `json:"timestamp" api:"required"`
	// The usage of the batched grid workflow.
	Usage ClientBatchedGridWorkflowCompleteWorkflowResponseUsage `json:"usage" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		JobID       respjson.Field
		Name        respjson.Field
		Outputs     respjson.Field
		Status      respjson.Field
		Timestamp   respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ClientBatchedGridWorkflowCompleteWorkflowResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientBatchedGridWorkflowCompleteWorkflowResponse) UnmarshalJSON

type ClientBatchedGridWorkflowCompleteWorkflowResponseUsage

type ClientBatchedGridWorkflowCompleteWorkflowResponseUsage struct {
	// The cost in credits for the agents.
	CostPerAgent float64 `json:"cost_per_agent" api:"required"`
	// The number of input tokens.
	InputTokens int64 `json:"input_tokens" api:"required"`
	// The number of output tokens.
	OutputTokens int64 `json:"output_tokens" api:"required"`
	// The cost in credits for the tokens.
	TokenCost float64 `json:"token_cost" api:"required"`
	// The total number of tokens.
	TotalTokens int64 `json:"total_tokens" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CostPerAgent respjson.Field
		InputTokens  respjson.Field
		OutputTokens respjson.Field
		TokenCost    respjson.Field
		TotalTokens  respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The usage of the batched grid workflow.

func (ClientBatchedGridWorkflowCompleteWorkflowResponseUsage) RawJSON

Returns the unmodified JSON received from the API

func (*ClientBatchedGridWorkflowCompleteWorkflowResponseUsage) UnmarshalJSON

type ClientBatchedGridWorkflowService

type ClientBatchedGridWorkflowService struct {
	Options []option.RequestOption
}

ClientBatchedGridWorkflowService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientBatchedGridWorkflowService method instead.

func NewClientBatchedGridWorkflowService

func NewClientBatchedGridWorkflowService(opts ...option.RequestOption) (r ClientBatchedGridWorkflowService)

NewClientBatchedGridWorkflowService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientBatchedGridWorkflowService) CompleteWorkflow

Complete a batched grid workflow with the specified input data. Enables you to run a grid workflow with multiple agents and tasks in a single request.

type ClientGraphWorkflowExecuteWorkflowParams

type ClientGraphWorkflowExecuteWorkflowParams struct {
	// Whether to automatically compile the workflow for optimization.
	AutoCompile param.Opt[bool] `json:"auto_compile,omitzero"`
	// The description of the graph workflow.
	Description param.Opt[string] `json:"description,omitzero"`
	// Optional image path for vision-enabled agents.
	Img param.Opt[string] `json:"img,omitzero"`
	// The maximum number of execution loops for the workflow.
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// The name of the graph workflow.
	Name param.Opt[string] `json:"name,omitzero"`
	// The task to be executed by the workflow.
	Task param.Opt[string] `json:"task,omitzero"`
	// Whether to enable detailed logging.
	Verbose param.Opt[bool] `json:"verbose,omitzero"`
	// List of agent specifications to be used as nodes in the workflow graph.
	Agents []AgentSpecParam `json:"agents,omitzero"`
	// List of edges connecting nodes. Can be EdgeSpec objects or dictionaries with
	// 'source' and 'target' keys.
	Edges []ClientGraphWorkflowExecuteWorkflowParamsEdgeUnion `json:"edges,omitzero"`
	// List of node IDs that serve as ending points for the workflow.
	EndPoints []string `json:"end_points,omitzero"`
	// List of node IDs that serve as starting points for the workflow.
	EntryPoints []string `json:"entry_points,omitzero"`
	// contains filtered or unexported fields
}

func (ClientGraphWorkflowExecuteWorkflowParams) MarshalJSON

func (r ClientGraphWorkflowExecuteWorkflowParams) MarshalJSON() (data []byte, err error)

func (*ClientGraphWorkflowExecuteWorkflowParams) UnmarshalJSON

func (r *ClientGraphWorkflowExecuteWorkflowParams) UnmarshalJSON(data []byte) error

type ClientGraphWorkflowExecuteWorkflowParamsEdgeEdgeSpec

type ClientGraphWorkflowExecuteWorkflowParamsEdgeEdgeSpec struct {
	// The source node ID.
	Source string `json:"source" api:"required"`
	// The target node ID.
	Target string `json:"target" api:"required"`
	// Optional metadata for the edge.
	Metadata map[string]any `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

Schema for defining an edge between nodes in the workflow graph.

The properties Source, Target are required.

func (ClientGraphWorkflowExecuteWorkflowParamsEdgeEdgeSpec) MarshalJSON

func (r ClientGraphWorkflowExecuteWorkflowParamsEdgeEdgeSpec) MarshalJSON() (data []byte, err error)

func (*ClientGraphWorkflowExecuteWorkflowParamsEdgeEdgeSpec) UnmarshalJSON

type ClientGraphWorkflowExecuteWorkflowParamsEdgeUnion

type ClientGraphWorkflowExecuteWorkflowParamsEdgeUnion struct {
	OfEdgeSpec *ClientGraphWorkflowExecuteWorkflowParamsEdgeEdgeSpec `json:",omitzero,inline"`
	OfAnyMap   map[string]any                                        `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ClientGraphWorkflowExecuteWorkflowParamsEdgeUnion) MarshalJSON

func (*ClientGraphWorkflowExecuteWorkflowParamsEdgeUnion) UnmarshalJSON

type ClientGraphWorkflowExecuteWorkflowResponse

type ClientGraphWorkflowExecuteWorkflowResponse struct {
	// The job ID of the graph workflow.
	JobID string `json:"job_id" api:"required"`
	// The outputs of the graph workflow.
	Outputs any `json:"outputs" api:"required"`
	// The status of the graph workflow.
	Status string `json:"status" api:"required"`
	// The timestamp of the graph workflow execution.
	Timestamp string `json:"timestamp" api:"required"`
	// The usage statistics of the workflow.
	Usage ClientGraphWorkflowExecuteWorkflowResponseUsage `json:"usage" api:"required"`
	// The description of the graph workflow.
	Description string `json:"description" api:"nullable"`
	// The name of the graph workflow.
	Name string `json:"name" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		JobID       respjson.Field
		Outputs     respjson.Field
		Status      respjson.Field
		Timestamp   respjson.Field
		Usage       respjson.Field
		Description respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Output schema for GraphWorkflow completion responses.

func (ClientGraphWorkflowExecuteWorkflowResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientGraphWorkflowExecuteWorkflowResponse) UnmarshalJSON

func (r *ClientGraphWorkflowExecuteWorkflowResponse) UnmarshalJSON(data []byte) error

type ClientGraphWorkflowExecuteWorkflowResponseUsage

type ClientGraphWorkflowExecuteWorkflowResponseUsage struct {
	// The cost in credits for the agents.
	CostPerAgent float64 `json:"cost_per_agent" api:"required"`
	// The number of input tokens.
	InputTokens int64 `json:"input_tokens" api:"required"`
	// The number of output tokens.
	OutputTokens int64 `json:"output_tokens" api:"required"`
	// The cost in credits for the tokens.
	TokenCost float64 `json:"token_cost" api:"required"`
	// The total number of tokens.
	TotalTokens int64 `json:"total_tokens" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CostPerAgent respjson.Field
		InputTokens  respjson.Field
		OutputTokens respjson.Field
		TokenCost    respjson.Field
		TotalTokens  respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The usage statistics of the workflow.

func (ClientGraphWorkflowExecuteWorkflowResponseUsage) RawJSON

Returns the unmodified JSON received from the API

func (*ClientGraphWorkflowExecuteWorkflowResponseUsage) UnmarshalJSON

type ClientGraphWorkflowService

type ClientGraphWorkflowService struct {
	Options []option.RequestOption
}

ClientGraphWorkflowService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientGraphWorkflowService method instead.

func NewClientGraphWorkflowService

func NewClientGraphWorkflowService(opts ...option.RequestOption) (r ClientGraphWorkflowService)

NewClientGraphWorkflowService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientGraphWorkflowService) ExecuteWorkflow

Execute a graph workflow with directed agent nodes and edges. Enables complex multi-agent collaboration with parallel execution, automatic compilation, and comprehensive workflow orchestration.

type ClientMarketplaceNewAgentParams

type ClientMarketplaceNewAgentParams struct {
	// Number of items to return
	NumberOfItems param.Opt[int64] `json:"number_of_items,omitzero"`
	// contains filtered or unexported fields
}

func (ClientMarketplaceNewAgentParams) MarshalJSON

func (r ClientMarketplaceNewAgentParams) MarshalJSON() (data []byte, err error)

func (*ClientMarketplaceNewAgentParams) UnmarshalJSON

func (r *ClientMarketplaceNewAgentParams) UnmarshalJSON(data []byte) error

type ClientMarketplaceNewAgentResponse

type ClientMarketplaceNewAgentResponse struct {
	// List of marketplace prompts
	Prompts []ClientMarketplaceNewAgentResponsePrompt `json:"prompts" api:"required"`
	// Total number of prompts available
	TotalCount int64 `json:"total_count" api:"required"`
	// The status of the marketplace prompts response.
	Status string `json:"status" api:"nullable"`
	// The timestamp of the marketplace prompts response.
	Timestamp string `json:"timestamp" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Prompts     respjson.Field
		TotalCount  respjson.Field
		Status      respjson.Field
		Timestamp   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Response schema for marketplace prompts endpoint.

func (ClientMarketplaceNewAgentResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientMarketplaceNewAgentResponse) UnmarshalJSON

func (r *ClientMarketplaceNewAgentResponse) UnmarshalJSON(data []byte) error

type ClientMarketplaceNewAgentResponsePrompt

type ClientMarketplaceNewAgentResponsePrompt struct {
	// Unique identifier for the prompt
	ID string `json:"id" api:"required"`
	// Timestamp when the prompt was created
	CreatedAt string `json:"created_at" api:"required"`
	// ID of the user who created the prompt
	UserID string `json:"user_id" api:"required"`
	// Category name(s) - can be string or list
	Category ClientMarketplaceNewAgentResponsePromptCategoryUnion `json:"category" api:"nullable"`
	// Description of the prompt
	Description string `json:"description" api:"nullable"`
	// Associated links - can be list of dicts or strings
	Links ClientMarketplaceNewAgentResponsePromptLinksUnion `json:"links" api:"nullable"`
	// Name of the prompt
	Name string `json:"name" api:"nullable"`
	// The actual prompt text
	Prompt string `json:"prompt" api:"nullable"`
	// Status of the prompt
	Status string `json:"status" api:"nullable"`
	// Tags associated with the prompt
	Tags string `json:"tags" api:"nullable"`
	// Use cases - can be dict or list of dicts
	UseCases ClientMarketplaceNewAgentResponsePromptUseCasesUnion `json:"use_cases" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		UserID      respjson.Field
		Category    respjson.Field
		Description respjson.Field
		Links       respjson.Field
		Name        respjson.Field
		Prompt      respjson.Field
		Status      respjson.Field
		Tags        respjson.Field
		UseCases    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Schema for marketplace prompts from the swarms_cloud_prompts table.

func (ClientMarketplaceNewAgentResponsePrompt) RawJSON

Returns the unmodified JSON received from the API

func (*ClientMarketplaceNewAgentResponsePrompt) UnmarshalJSON

func (r *ClientMarketplaceNewAgentResponsePrompt) UnmarshalJSON(data []byte) error

type ClientMarketplaceNewAgentResponsePromptCategoryUnion

type ClientMarketplaceNewAgentResponsePromptCategoryUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]string] instead of an object.
	OfStringArray []string `json:",inline"`
	JSON          struct {
		OfString      respjson.Field
		OfStringArray respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ClientMarketplaceNewAgentResponsePromptCategoryUnion contains all possible properties and values from [string], [[]string].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfString OfStringArray]

func (ClientMarketplaceNewAgentResponsePromptCategoryUnion) AsString

func (ClientMarketplaceNewAgentResponsePromptCategoryUnion) AsStringArray

func (ClientMarketplaceNewAgentResponsePromptCategoryUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ClientMarketplaceNewAgentResponsePromptCategoryUnion) UnmarshalJSON

type ClientMarketplaceNewAgentResponsePromptLinksUnion

type ClientMarketplaceNewAgentResponsePromptLinksUnion struct {
	// This field will be present if the value is a [[]map[string]any] instead of an
	// object.
	OfMapOfAnyMap []map[string]any `json:",inline"`
	// This field will be present if the value is a [[]string] instead of an object.
	OfStringArray []string `json:",inline"`
	JSON          struct {
		OfMapOfAnyMap respjson.Field
		OfStringArray respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ClientMarketplaceNewAgentResponsePromptLinksUnion contains all possible properties and values from [[]map[string]any], [[]string].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfMapOfAnyMap OfStringArray]

func (ClientMarketplaceNewAgentResponsePromptLinksUnion) AsMapOfAnyMap

func (u ClientMarketplaceNewAgentResponsePromptLinksUnion) AsMapOfAnyMap() (v []map[string]any)

func (ClientMarketplaceNewAgentResponsePromptLinksUnion) AsStringArray

func (ClientMarketplaceNewAgentResponsePromptLinksUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ClientMarketplaceNewAgentResponsePromptLinksUnion) UnmarshalJSON

type ClientMarketplaceNewAgentResponsePromptUseCasesUnion

type ClientMarketplaceNewAgentResponsePromptUseCasesUnion struct {
	// This field will be present if the value is a [any] instead of an object.
	OfClientMarketplaceNewAgentResponsePromptUseCasesMapItem any `json:",inline"`
	// This field will be present if the value is a [[]map[string]any] instead of an
	// object.
	OfMapOfAnyMap []map[string]any `json:",inline"`
	JSON          struct {
		OfClientMarketplaceNewAgentResponsePromptUseCasesMapItem respjson.Field
		OfMapOfAnyMap                                            respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ClientMarketplaceNewAgentResponsePromptUseCasesUnion contains all possible properties and values from [map[string]any], [[]map[string]any].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfClientMarketplaceNewAgentResponsePromptUseCasesMapItem OfMapOfAnyMap]

func (ClientMarketplaceNewAgentResponsePromptUseCasesUnion) AsAnyMap

func (ClientMarketplaceNewAgentResponsePromptUseCasesUnion) AsMapOfAnyMap

func (ClientMarketplaceNewAgentResponsePromptUseCasesUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ClientMarketplaceNewAgentResponsePromptUseCasesUnion) UnmarshalJSON

type ClientMarketplaceService

type ClientMarketplaceService struct {
	Options []option.RequestOption
}

ClientMarketplaceService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientMarketplaceService method instead.

func NewClientMarketplaceService

func NewClientMarketplaceService(opts ...option.RequestOption) (r ClientMarketplaceService)

NewClientMarketplaceService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientMarketplaceService) NewAgent

Retrieve free agents from the marketplace.

type ClientRateGetLimitsResponse

type ClientRateGetLimitsResponse struct {
	// The configured rate limits based on the user's subscription tier.
	Limits ClientRateGetLimitsResponseLimits `json:"limits" api:"required"`
	// Current rate limit usage information for different time windows.
	RateLimits ClientRateGetLimitsResponseRateLimits `json:"rate_limits" api:"required"`
	// The user's current subscription tier (free or premium).
	Tier string `json:"tier" api:"required"`
	// ISO timestamp when the rate limits information was retrieved.
	Timestamp string `json:"timestamp" api:"required"`
	// Indicates whether the rate limits request was successful.
	Success bool `json:"success" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Limits      respjson.Field
		RateLimits  respjson.Field
		Tier        respjson.Field
		Timestamp   respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ClientRateGetLimitsResponse) RawJSON

func (r ClientRateGetLimitsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ClientRateGetLimitsResponse) UnmarshalJSON

func (r *ClientRateGetLimitsResponse) UnmarshalJSON(data []byte) error

type ClientRateGetLimitsResponseLimits

type ClientRateGetLimitsResponseLimits struct {
	// The maximum number of requests allowed per day.
	MaximumRequestsPerDay int64 `json:"maximum_requests_per_day" api:"required"`
	// The maximum number of requests allowed per hour.
	MaximumRequestsPerHour int64 `json:"maximum_requests_per_hour" api:"required"`
	// The maximum number of requests allowed per minute.
	MaximumRequestsPerMinute int64 `json:"maximum_requests_per_minute" api:"required"`
	// The maximum number of tokens allowed per agent.
	TokensPerAgent int64 `json:"tokens_per_agent" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		MaximumRequestsPerDay    respjson.Field
		MaximumRequestsPerHour   respjson.Field
		MaximumRequestsPerMinute respjson.Field
		TokensPerAgent           respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The configured rate limits based on the user's subscription tier.

func (ClientRateGetLimitsResponseLimits) RawJSON

Returns the unmodified JSON received from the API

func (*ClientRateGetLimitsResponseLimits) UnmarshalJSON

func (r *ClientRateGetLimitsResponseLimits) UnmarshalJSON(data []byte) error

type ClientRateGetLimitsResponseRateLimits

type ClientRateGetLimitsResponseRateLimits struct {
	// Rate limit information for the last day.
	Day RateLimitWindow `json:"day" api:"required"`
	// Rate limit information for the last hour.
	Hour RateLimitWindow `json:"hour" api:"required"`
	// Rate limit information for the last minute.
	Minute RateLimitWindow `json:"minute" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Day         respjson.Field
		Hour        respjson.Field
		Minute      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Current rate limit usage information for different time windows.

func (ClientRateGetLimitsResponseRateLimits) RawJSON

Returns the unmodified JSON received from the API

func (*ClientRateGetLimitsResponseRateLimits) UnmarshalJSON

func (r *ClientRateGetLimitsResponseRateLimits) UnmarshalJSON(data []byte) error

type ClientRateService

type ClientRateService struct {
	Options []option.RequestOption
}

ClientRateService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientRateService method instead.

func NewClientRateService

func NewClientRateService(opts ...option.RequestOption) (r ClientRateService)

NewClientRateService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientRateService) GetLimits

Get the rate limits and current usage for the user associated with the provided API key.

type ClientService

type ClientService struct {
	Options             []option.RequestOption
	Rate                ClientRateService
	AutoSwarmBuilder    ClientAutoSwarmBuilderService
	AdvancedResearch    ClientAdvancedResearchService
	Tools               ClientToolService
	Marketplace         ClientMarketplaceService
	BatchedGridWorkflow ClientBatchedGridWorkflowService
	GraphWorkflow       ClientGraphWorkflowService
}

ClientService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientService method instead.

func NewClientService

func NewClientService(opts ...option.RequestOption) (r ClientService)

NewClientService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type ClientToolListAvailableResponse

type ClientToolListAvailableResponse struct {
	// The status of the available tools.
	Status string `json:"status" api:"nullable"`
	// The list of available tools.
	Tools []string `json:"tools" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Status      respjson.Field
		Tools       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ClientToolListAvailableResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ClientToolListAvailableResponse) UnmarshalJSON

func (r *ClientToolListAvailableResponse) UnmarshalJSON(data []byte) error

type ClientToolService

type ClientToolService struct {
	Options []option.RequestOption
}

ClientToolService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewClientToolService method instead.

func NewClientToolService

func NewClientToolService(opts ...option.RequestOption) (r ClientToolService)

NewClientToolService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ClientToolService) ListAvailable

func (r *ClientToolService) ListAvailable(ctx context.Context, opts ...option.RequestOption) (res *ClientToolListAvailableResponse, err error)

Retrieve comprehensive information about all available tools and capabilities supported by the Swarms API.

type Error

type Error = apierror.Error

type GetRootResponse

type GetRootResponse = any

type HealthCheckResponse

type HealthCheckResponse struct {
	Status string `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (HealthCheckResponse) RawJSON

func (r HealthCheckResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*HealthCheckResponse) UnmarshalJSON

func (r *HealthCheckResponse) UnmarshalJSON(data []byte) error

type HealthService

type HealthService struct {
	Options []option.RequestOption
}

HealthService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewHealthService method instead.

func NewHealthService

func NewHealthService(opts ...option.RequestOption) (r HealthService)

NewHealthService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*HealthService) Check

func (r *HealthService) Check(ctx context.Context, opts ...option.RequestOption) (res *HealthCheckResponse, err error)

Health

type McpConnectionParam

type McpConnectionParam struct {
	// Authentication token for accessing the MCP server
	AuthorizationToken param.Opt[string] `json:"authorization_token,omitzero"`
	// Timeout for the MCP server
	Timeout param.Opt[int64] `json:"timeout,omitzero"`
	// The transport protocol to use for the MCP server
	Transport param.Opt[string] `json:"transport,omitzero"`
	// The type of connection, defaults to 'mcp'
	Type param.Opt[string] `json:"type,omitzero"`
	// The URL endpoint for the MCP server
	URL param.Opt[string] `json:"url,omitzero"`
	// Headers to send to the MCP server
	Headers map[string]string `json:"headers,omitzero"`
	// Dictionary containing configuration settings for MCP tools
	ToolConfigurations map[string]any `json:"tool_configurations,omitzero"`
	ExtraFields        map[string]any `json:"-"`
	// contains filtered or unexported fields
}

func (McpConnectionParam) MarshalJSON

func (r McpConnectionParam) MarshalJSON() (data []byte, err error)

func (*McpConnectionParam) UnmarshalJSON

func (r *McpConnectionParam) UnmarshalJSON(data []byte) error

type ModelListAvailableResponse

type ModelListAvailableResponse struct {
	Models  any  `json:"models"`
	Success bool `json:"success" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Models      respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ModelListAvailableResponse) RawJSON

func (r ModelListAvailableResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ModelListAvailableResponse) UnmarshalJSON

func (r *ModelListAvailableResponse) UnmarshalJSON(data []byte) error

type ModelService

type ModelService struct {
	Options []option.RequestOption
}

ModelService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewModelService method instead.

func NewModelService

func NewModelService(opts ...option.RequestOption) (r ModelService)

NewModelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ModelService) ListAvailable

func (r *ModelService) ListAvailable(ctx context.Context, opts ...option.RequestOption) (res *ModelListAvailableResponse, err error)

Get all available models.

type RateLimitWindow

type RateLimitWindow struct {
	// The number of requests made in this time window.
	Count int64 `json:"count" api:"required"`
	// Whether the rate limit has been exceeded for this time window.
	Exceeded bool `json:"exceeded" api:"required"`
	// The maximum number of requests allowed in this time window.
	Limit int64 `json:"limit" api:"required"`
	// The number of requests remaining before hitting the limit.
	Remaining int64 `json:"remaining" api:"required"`
	// ISO timestamp when the rate limit will reset.
	ResetTime string `json:"reset_time" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Count       respjson.Field
		Exceeded    respjson.Field
		Limit       respjson.Field
		Remaining   respjson.Field
		ResetTime   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (RateLimitWindow) RawJSON

func (r RateLimitWindow) RawJSON() string

Returns the unmodified JSON received from the API

func (*RateLimitWindow) UnmarshalJSON

func (r *RateLimitWindow) UnmarshalJSON(data []byte) error

type ReasoningAgentListTypesResponse

type ReasoningAgentListTypesResponse map[string]any

type ReasoningAgentNewCompletionParams

type ReasoningAgentNewCompletionParams struct {
	// The unique name assigned to the reasoning agent.
	AgentName param.Opt[string] `json:"agent_name,omitzero"`
	// A detailed explanation of the reasoning agent's purpose and capabilities.
	Description param.Opt[string] `json:"description,omitzero"`
	// The maximum number of times the reasoning agent is allowed to repeat its task.
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// The memory capacity for the reasoning agent.
	MemoryCapacity param.Opt[int64] `json:"memory_capacity,omitzero"`
	// The name of the AI model that the reasoning agent will utilize.
	ModelName param.Opt[string] `json:"model_name,omitzero"`
	// The number of knowledge items to use for the reasoning agent.
	NumKnowledgeItems param.Opt[int64] `json:"num_knowledge_items,omitzero"`
	// The number of samples to generate for the reasoning agent.
	NumSamples param.Opt[int64] `json:"num_samples,omitzero"`
	// The initial instruction or context provided to the reasoning agent.
	SystemPrompt param.Opt[string] `json:"system_prompt,omitzero"`
	// The task to be completed by the reasoning agent.
	Task param.Opt[string] `json:"task,omitzero"`
	// The type of output format for the reasoning agent.
	//
	// Any of "list", "dict", "dictionary", "string", "str", "final", "last", "json",
	// "all", "yaml", "xml", "dict-all-except-first", "str-all-except-first",
	// "basemodel", "dict-final", "list-final".
	OutputType ReasoningAgentNewCompletionParamsOutputType `json:"output_type,omitzero"`
	// The type of reasoning swarm to use (e.g., reasoning duo, self-consistency, IRE).
	//
	// Any of "reasoning-duo", "self-consistency", "ire", "reasoning-agent",
	// "consistency-agent", "ire-agent", "ReflexionAgent", "GKPAgent", "AgentJudge".
	SwarmType ReasoningAgentNewCompletionParamsSwarmType `json:"swarm_type,omitzero"`
	// contains filtered or unexported fields
}

func (ReasoningAgentNewCompletionParams) MarshalJSON

func (r ReasoningAgentNewCompletionParams) MarshalJSON() (data []byte, err error)

func (*ReasoningAgentNewCompletionParams) UnmarshalJSON

func (r *ReasoningAgentNewCompletionParams) UnmarshalJSON(data []byte) error

type ReasoningAgentNewCompletionParamsOutputType

type ReasoningAgentNewCompletionParamsOutputType string

The type of output format for the reasoning agent.

const (
	ReasoningAgentNewCompletionParamsOutputTypeList               ReasoningAgentNewCompletionParamsOutputType = "list"
	ReasoningAgentNewCompletionParamsOutputTypeDict               ReasoningAgentNewCompletionParamsOutputType = "dict"
	ReasoningAgentNewCompletionParamsOutputTypeDictionary         ReasoningAgentNewCompletionParamsOutputType = "dictionary"
	ReasoningAgentNewCompletionParamsOutputTypeString             ReasoningAgentNewCompletionParamsOutputType = "string"
	ReasoningAgentNewCompletionParamsOutputTypeStr                ReasoningAgentNewCompletionParamsOutputType = "str"
	ReasoningAgentNewCompletionParamsOutputTypeFinal              ReasoningAgentNewCompletionParamsOutputType = "final"
	ReasoningAgentNewCompletionParamsOutputTypeLast               ReasoningAgentNewCompletionParamsOutputType = "last"
	ReasoningAgentNewCompletionParamsOutputTypeJson               ReasoningAgentNewCompletionParamsOutputType = "json"
	ReasoningAgentNewCompletionParamsOutputTypeAll                ReasoningAgentNewCompletionParamsOutputType = "all"
	ReasoningAgentNewCompletionParamsOutputTypeYaml               ReasoningAgentNewCompletionParamsOutputType = "yaml"
	ReasoningAgentNewCompletionParamsOutputTypeXml                ReasoningAgentNewCompletionParamsOutputType = "xml"
	ReasoningAgentNewCompletionParamsOutputTypeDictAllExceptFirst ReasoningAgentNewCompletionParamsOutputType = "dict-all-except-first"
	ReasoningAgentNewCompletionParamsOutputTypeStrAllExceptFirst  ReasoningAgentNewCompletionParamsOutputType = "str-all-except-first"
	ReasoningAgentNewCompletionParamsOutputTypeBasemodel          ReasoningAgentNewCompletionParamsOutputType = "basemodel"
	ReasoningAgentNewCompletionParamsOutputTypeDictFinal          ReasoningAgentNewCompletionParamsOutputType = "dict-final"
	ReasoningAgentNewCompletionParamsOutputTypeListFinal          ReasoningAgentNewCompletionParamsOutputType = "list-final"
)

type ReasoningAgentNewCompletionParamsSwarmType

type ReasoningAgentNewCompletionParamsSwarmType string

The type of reasoning swarm to use (e.g., reasoning duo, self-consistency, IRE).

const (
	ReasoningAgentNewCompletionParamsSwarmTypeReasoningDuo     ReasoningAgentNewCompletionParamsSwarmType = "reasoning-duo"
	ReasoningAgentNewCompletionParamsSwarmTypeSelfConsistency  ReasoningAgentNewCompletionParamsSwarmType = "self-consistency"
	ReasoningAgentNewCompletionParamsSwarmTypeIre              ReasoningAgentNewCompletionParamsSwarmType = "ire"
	ReasoningAgentNewCompletionParamsSwarmTypeReasoningAgent   ReasoningAgentNewCompletionParamsSwarmType = "reasoning-agent"
	ReasoningAgentNewCompletionParamsSwarmTypeConsistencyAgent ReasoningAgentNewCompletionParamsSwarmType = "consistency-agent"
	ReasoningAgentNewCompletionParamsSwarmTypeIreAgent         ReasoningAgentNewCompletionParamsSwarmType = "ire-agent"
	ReasoningAgentNewCompletionParamsSwarmTypeReflexionAgent   ReasoningAgentNewCompletionParamsSwarmType = "ReflexionAgent"
	ReasoningAgentNewCompletionParamsSwarmTypeGkpAgent         ReasoningAgentNewCompletionParamsSwarmType = "GKPAgent"
	ReasoningAgentNewCompletionParamsSwarmTypeAgentJudge       ReasoningAgentNewCompletionParamsSwarmType = "AgentJudge"
)

type ReasoningAgentNewCompletionResponse

type ReasoningAgentNewCompletionResponse map[string]any

type ReasoningAgentService

type ReasoningAgentService struct {
	Options []option.RequestOption
}

ReasoningAgentService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewReasoningAgentService method instead.

func NewReasoningAgentService

func NewReasoningAgentService(opts ...option.RequestOption) (r ReasoningAgentService)

NewReasoningAgentService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ReasoningAgentService) ListTypes

Get the types of reasoning agents available.

func (*ReasoningAgentService) NewCompletion

Run a reasoning agent with the specified task.

type SwarmBatchRunParams

type SwarmBatchRunParams struct {
	Body []SwarmSpecParam
	// contains filtered or unexported fields
}

func (SwarmBatchRunParams) MarshalJSON

func (r SwarmBatchRunParams) MarshalJSON() (data []byte, err error)

func (*SwarmBatchRunParams) UnmarshalJSON

func (r *SwarmBatchRunParams) UnmarshalJSON(data []byte) error

type SwarmBatchRunResponse

type SwarmBatchRunResponse map[string]any

type SwarmBatchService

type SwarmBatchService struct {
	Options []option.RequestOption
}

SwarmBatchService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSwarmBatchService method instead.

func NewSwarmBatchService

func NewSwarmBatchService(opts ...option.RequestOption) (r SwarmBatchService)

NewSwarmBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*SwarmBatchService) Run

Run a batch of swarms with the specified tasks using a thread pool.

type SwarmCheckAvailableResponse

type SwarmCheckAvailableResponse struct {
	Success    bool     `json:"success" api:"nullable"`
	SwarmTypes []string `json:"swarm_types" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Success     respjson.Field
		SwarmTypes  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SwarmCheckAvailableResponse) RawJSON

func (r SwarmCheckAvailableResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SwarmCheckAvailableResponse) UnmarshalJSON

func (r *SwarmCheckAvailableResponse) UnmarshalJSON(data []byte) error

type SwarmGetLogsResponse

type SwarmGetLogsResponse struct {
	Count     int64  `json:"count" api:"nullable"`
	Logs      any    `json:"logs"`
	Status    string `json:"status" api:"nullable"`
	Timestamp string `json:"timestamp" api:"nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Count       respjson.Field
		Logs        respjson.Field
		Status      respjson.Field
		Timestamp   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SwarmGetLogsResponse) RawJSON

func (r SwarmGetLogsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SwarmGetLogsResponse) UnmarshalJSON

func (r *SwarmGetLogsResponse) UnmarshalJSON(data []byte) error

type SwarmRunParams

type SwarmRunParams struct {
	SwarmSpec SwarmSpecParam
	// contains filtered or unexported fields
}

func (SwarmRunParams) MarshalJSON

func (r SwarmRunParams) MarshalJSON() (data []byte, err error)

func (*SwarmRunParams) UnmarshalJSON

func (r *SwarmRunParams) UnmarshalJSON(data []byte) error

type SwarmRunResponse

type SwarmRunResponse struct {
	// The description of the swarm.
	Description string `json:"description" api:"required"`
	// The execution time of the swarm.
	ExecutionTime float64 `json:"execution_time" api:"required"`
	// The unique identifier for the swarm completion.
	JobID string `json:"job_id" api:"required"`
	// The number of agents in the swarm.
	NumberOfAgents int64 `json:"number_of_agents" api:"required"`
	// The output of the swarm.
	Output any `json:"output" api:"required"`
	// The service tier of the swarm.
	ServiceTier string `json:"service_tier" api:"required"`
	// The status of the swarm completion.
	Status string `json:"status" api:"required"`
	// The name of the swarm.
	SwarmName string `json:"swarm_name" api:"required"`
	// The type of the swarm.
	SwarmType string `json:"swarm_type" api:"required"`
	// The usage of the swarm.
	Usage map[string]any `json:"usage" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description    respjson.Field
		ExecutionTime  respjson.Field
		JobID          respjson.Field
		NumberOfAgents respjson.Field
		Output         respjson.Field
		ServiceTier    respjson.Field
		Status         respjson.Field
		SwarmName      respjson.Field
		SwarmType      respjson.Field
		Usage          respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SwarmRunResponse) RawJSON

func (r SwarmRunResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SwarmRunResponse) UnmarshalJSON

func (r *SwarmRunResponse) UnmarshalJSON(data []byte) error

type SwarmService

type SwarmService struct {
	Options []option.RequestOption
	Batch   SwarmBatchService
}

SwarmService contains methods and other services that help with interacting with the swarms-client API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSwarmService method instead.

func NewSwarmService

func NewSwarmService(opts ...option.RequestOption) (r SwarmService)

NewSwarmService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*SwarmService) CheckAvailable

func (r *SwarmService) CheckAvailable(ctx context.Context, opts ...option.RequestOption) (res *SwarmCheckAvailableResponse, err error)

Check the available swarm types.

func (*SwarmService) GetLogs

func (r *SwarmService) GetLogs(ctx context.Context, opts ...option.RequestOption) (res *SwarmGetLogsResponse, err error)

Get all API request logs for all API keys associated with the user identified by the provided API key, excluding any logs that contain a client_ip field in their data.

func (*SwarmService) Run

func (r *SwarmService) Run(ctx context.Context, body SwarmRunParams, opts ...option.RequestOption) (res *SwarmRunResponse, err error)

Run a swarm with the specified task. Supports streaming when stream=True.

type SwarmSpecMessagesUnionParam

type SwarmSpecMessagesUnionParam struct {
	OfMapOfAnyMap []map[string]any `json:",omitzero,inline"`
	OfAnyMap      map[string]any   `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SwarmSpecMessagesUnionParam) MarshalJSON

func (u SwarmSpecMessagesUnionParam) MarshalJSON() ([]byte, error)

func (*SwarmSpecMessagesUnionParam) UnmarshalJSON

func (u *SwarmSpecMessagesUnionParam) UnmarshalJSON(data []byte) error

type SwarmSpecParam

type SwarmSpecParam struct {
	// A comprehensive description of the swarm's objectives, capabilities, and
	// intended outcomes.
	Description param.Opt[string] `json:"description,omitzero"`
	// The number of loops to run per agent in the heavy swarm.
	HeavySwarmLoopsPerAgent param.Opt[int64] `json:"heavy_swarm_loops_per_agent,omitzero"`
	// The model name to use for the question agent in the heavy swarm.
	HeavySwarmQuestionAgentModelName param.Opt[string] `json:"heavy_swarm_question_agent_model_name,omitzero"`
	// The model name to use for the worker agent in the heavy swarm.
	HeavySwarmWorkerModelName param.Opt[string] `json:"heavy_swarm_worker_model_name,omitzero"`
	// An optional image URL that may be associated with the swarm's task or
	// representation.
	Img param.Opt[string] `json:"img,omitzero"`
	// The maximum number of execution loops allowed for the swarm, enabling repeated
	// processing if needed.
	MaxLoops param.Opt[int64] `json:"max_loops,omitzero"`
	// The name of the swarm, which serves as an identifier for the group of agents and
	// their collective task.
	Name param.Opt[string] `json:"name,omitzero"`
	// Instructions on how to rearrange the flow of tasks among agents, if applicable.
	RearrangeFlow param.Opt[string] `json:"rearrange_flow,omitzero"`
	// Guidelines or constraints that govern the behavior and interactions of the
	// agents within the swarm.
	Rules param.Opt[string] `json:"rules,omitzero"`
	// The service tier to use for processing. Options: 'standard' (default) or 'flex'
	// for lower cost but slower processing.
	ServiceTier param.Opt[string] `json:"service_tier,omitzero"`
	// A flag indicating whether the swarm should stream its output.
	Stream param.Opt[bool] `json:"stream,omitzero"`
	// The specific task or objective that the swarm is designed to accomplish.
	Task param.Opt[string] `json:"task,omitzero"`
	// A list of agents or specifications that define the agents participating in the
	// swarm.
	Agents []AgentSpecParam `json:"agents,omitzero"`
	// A list of messages that the swarm should complete.
	Messages SwarmSpecMessagesUnionParam `json:"messages,omitzero"`
	// The classification of the swarm, indicating its operational style and
	// methodology.
	//
	// Any of "AgentRearrange", "MixtureOfAgents", "SequentialWorkflow",
	// "ConcurrentWorkflow", "GroupChat", "MultiAgentRouter", "AutoSwarmBuilder",
	// "HiearchicalSwarm", "auto", "MajorityVoting", "MALT", "DeepResearchSwarm",
	// "CouncilAsAJudge", "InteractiveGroupChat", "HeavySwarm".
	SwarmType SwarmSpecSwarmType `json:"swarm_type,omitzero"`
	// A list of tasks that the swarm should complete.
	Tasks []string `json:"tasks,omitzero"`
	// contains filtered or unexported fields
}

func (SwarmSpecParam) MarshalJSON

func (r SwarmSpecParam) MarshalJSON() (data []byte, err error)

func (*SwarmSpecParam) UnmarshalJSON

func (r *SwarmSpecParam) UnmarshalJSON(data []byte) error

type SwarmSpecSwarmType

type SwarmSpecSwarmType string

The classification of the swarm, indicating its operational style and methodology.

const (
	SwarmSpecSwarmTypeAgentRearrange       SwarmSpecSwarmType = "AgentRearrange"
	SwarmSpecSwarmTypeMixtureOfAgents      SwarmSpecSwarmType = "MixtureOfAgents"
	SwarmSpecSwarmTypeSequentialWorkflow   SwarmSpecSwarmType = "SequentialWorkflow"
	SwarmSpecSwarmTypeConcurrentWorkflow   SwarmSpecSwarmType = "ConcurrentWorkflow"
	SwarmSpecSwarmTypeGroupChat            SwarmSpecSwarmType = "GroupChat"
	SwarmSpecSwarmTypeMultiAgentRouter     SwarmSpecSwarmType = "MultiAgentRouter"
	SwarmSpecSwarmTypeAutoSwarmBuilder     SwarmSpecSwarmType = "AutoSwarmBuilder"
	SwarmSpecSwarmTypeHiearchicalSwarm     SwarmSpecSwarmType = "HiearchicalSwarm"
	SwarmSpecSwarmTypeAuto                 SwarmSpecSwarmType = "auto"
	SwarmSpecSwarmTypeMajorityVoting       SwarmSpecSwarmType = "MajorityVoting"
	SwarmSpecSwarmTypeMalt                 SwarmSpecSwarmType = "MALT"
	SwarmSpecSwarmTypeDeepResearchSwarm    SwarmSpecSwarmType = "DeepResearchSwarm"
	SwarmSpecSwarmTypeCouncilAsAJudge      SwarmSpecSwarmType = "CouncilAsAJudge"
	SwarmSpecSwarmTypeInteractiveGroupChat SwarmSpecSwarmType = "InteractiveGroupChat"
	SwarmSpecSwarmTypeHeavySwarm           SwarmSpecSwarmType = "HeavySwarm"
)

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
packages
shared

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL