aidr

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 14 Imported by: 0

README

CrowdStrike AIDR Go SDK

Go SDK for CrowdStrike AIDR.

Installation

go get github.com/crowdstrike/aidr-go

Requirements

Go v1.24 or higher.

Usage

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/crowdstrike/aidr-go"
    "github.com/crowdstrike/aidr-go/option"
)

func main() {
    ctx := context.Background()

    client := aidr.NewClient(
        option.WithBaseURLTemplate("https://api.eu-1.crowdstrike.com/aidr/{SERVICE_NAME}"),
        option.WithToken("your-api-token"),
    )

    params := aidr.AIGuardGuardChatCompletionsParams{
        GuardInput: map[string]any{
            "messages": []any{
                map[string]any{
                    "role":    "user",
                    "content": "Your prompt here",
                },
            },
        },
        EventType: aidr.AIGuardGuardChatCompletionsParamsEventTypeInput,
    }

    response, err := client.AIGuard.GuardChatCompletions(ctx, params)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Request ID: %s\n", response.RequestID)
    fmt.Printf("Status: %s\n", response.Status)
    fmt.Printf("Blocked: %v\n", response.Result.Blocked)
}
Request options

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 := aidr.NewClient(
	// Add a header to every request made by the client.
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.AIGuard.GuardChatCompletions(context.TODO(), ...,
	// Override the header.
	option.WithHeader("X-Some-Header", "some_other_custom_header_info")),
)

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

See the full list of request options.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, HTTP/408, HTTP/409, HTTP/429, and HTTP/5xx errors.

Use the WithMaxRetries option to configure or disable this:

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

// Override per-request.
client.AIGuard.GuardChatCompletions(
	context.TODO(),
	aidr.AIGuardGuardChatCompletionsParams{
		GuardInput: map[string]any{
			"messages": []any{
				map[string]any{
					"role":    "user",
					"content": "Your prompt here",
				},
			},
		},
		EventType: aidr.AIGuardGuardChatCompletionsParamsEventTypeInput,
	},
	option.WithMaxRetries(5),
)
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.AIGuard.GuardChatCompletions(
	ctx,
	aidr.AIGuardGuardChatCompletionsParams{
		GuardInput: map[string]any{
			"messages": []any{
				map[string]any{
					"role":    "user",
					"content": "Your prompt here",
				},
			},
		},
		EventType: aidr.AIGuardGuardChatCompletionsParamsEventTypeInput,
	},
	// This sets the per-retry timeout.
	option.WithRequestTimeout(20*time.Second),
)

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 (AIDR_API_TOKEN, AIDR_BASE_URL_TEMPLATE). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename, 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 AIGuardGetAsyncRequestResponse

type AIGuardGetAsyncRequestResponse struct {
	// A unique identifier assigned to each request made to the API. It is used to
	// track and identify a specific request and its associated data. The `request_id`
	// can be helpful for troubleshooting, auditing, and tracing the flow of requests
	// within the system. It allows users to reference and retrieve information related
	// to a particular request, such as the response, parameters, and raw data
	// associated with that specific request.
	//
	// “`
	// "request_id":"prq_x6fdiizbon6j3bsdvnpmwxsz2aan7fqd"
	// “`
	RequestID string `json:"request_id,required"`
	// The timestamp indicates the exact moment when a request is made to the API. It
	// represents the date and time at which the request was initiated by the client.
	// The `request_time` is useful for tracking and analyzing the timing of requests,
	// measuring response times, and monitoring performance metrics. It allows users to
	// determine the duration between the request initiation and the corresponding
	// response, aiding in the assessment of API performance and latency.
	//
	// “`
	// "request_time":"2022-09-21T17:24:33.105Z"
	// “`
	RequestTime time.Time `json:"request_time,required" format:"date-time"`
	// Duration it takes for the API to process a request and generate a response. It
	// represents the elapsed time from when the request is received by the API to when
	// the corresponding response is returned to the client.
	//
	// “`
	// "response_time":"2022-09-21T17:24:34.007Z"
	// “`
	ResponseTime time.Time `json:"response_time,required" format:"date-time"`
	// It represents the status or outcome of the API request made for IP information.
	// It indicates the current state or condition of the request and provides
	// information on the success or failure of the request.
	//
	// “`
	// "status":"success"
	// “`
	Status string `json:"status,required"`
	Result any    `json:"result"`
	// Provides a concise and brief overview of the purpose or primary objective of the
	// API endpoint. It serves as a high-level summary or description of the
	// functionality or feature offered by the endpoint.
	Summary string `json:"summary"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		RequestID    respjson.Field
		RequestTime  respjson.Field
		ResponseTime respjson.Field
		Status       respjson.Field
		Result       respjson.Field
		Summary      respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Pangea standard response schema

func (AIGuardGetAsyncRequestResponse) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGetAsyncRequestResponse) UnmarshalJSON

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

type AIGuardGuardChatCompletionsParams

type AIGuardGuardChatCompletionsParams struct {
	// 'messages' contains Prompt content and role array in JSON format. The `content`
	// is the multimodel text or image input that will be analyzed. Additional
	// properties such as 'tools' may be provided for analysis.
	GuardInput any `json:"guard_input,omitzero,required"`
	// Id of source application/agent
	AppID param.Opt[string] `json:"app_id,omitzero"`
	// (AIDR) collector instance id.
	CollectorInstanceID param.Opt[string] `json:"collector_instance_id,omitzero"`
	// Underlying LLM. Example: 'OpenAI'.
	LlmProvider param.Opt[string] `json:"llm_provider,omitzero"`
	// Model used to perform the event. Example: 'gpt'.
	Model param.Opt[string] `json:"model,omitzero"`
	// Model version used to perform the event. Example: '3.5'.
	ModelVersion param.Opt[string] `json:"model_version,omitzero"`
	// IP address of user or app or agent.
	SourceIP param.Opt[string] `json:"source_ip,omitzero"`
	// Location of user or app or agent.
	SourceLocation param.Opt[string] `json:"source_location,omitzero"`
	// For gateway-like integrations with multi-tenant support.
	TenantID param.Opt[string] `json:"tenant_id,omitzero"`
	// User/Service account id/service account
	UserID param.Opt[string] `json:"user_id,omitzero"`
	// (AIDR) Event Type.
	//
	// Any of "input", "output", "tool_input", "tool_output", "tool_listing".
	EventType AIGuardGuardChatCompletionsParamsEventType `json:"event_type,omitzero"`
	// (AIDR) Logging schema.
	ExtraInfo AIGuardGuardChatCompletionsParamsExtraInfo `json:"extra_info,omitzero"`
	// contains filtered or unexported fields
}

func (AIGuardGuardChatCompletionsParams) MarshalJSON

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

func (*AIGuardGuardChatCompletionsParams) UnmarshalJSON

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

type AIGuardGuardChatCompletionsParamsEventType

type AIGuardGuardChatCompletionsParamsEventType string

(AIDR) Event Type.

const (
	AIGuardGuardChatCompletionsParamsEventTypeInput       AIGuardGuardChatCompletionsParamsEventType = "input"
	AIGuardGuardChatCompletionsParamsEventTypeOutput      AIGuardGuardChatCompletionsParamsEventType = "output"
	AIGuardGuardChatCompletionsParamsEventTypeToolInput   AIGuardGuardChatCompletionsParamsEventType = "tool_input"
	AIGuardGuardChatCompletionsParamsEventTypeToolOutput  AIGuardGuardChatCompletionsParamsEventType = "tool_output"
	AIGuardGuardChatCompletionsParamsEventTypeToolListing AIGuardGuardChatCompletionsParamsEventType = "tool_listing"
)

type AIGuardGuardChatCompletionsParamsExtraInfo

type AIGuardGuardChatCompletionsParamsExtraInfo struct {
	// The group of subject actor.
	ActorGroup param.Opt[string] `json:"actor_group,omitzero"`
	// Name of subject actor/service account.
	ActorName param.Opt[string] `json:"actor_name,omitzero"`
	// The group of source application/agent.
	AppGroup param.Opt[string] `json:"app_group,omitzero"`
	// Name of source application/agent.
	AppName param.Opt[string] `json:"app_name,omitzero"`
	// Version of the source application/agent.
	AppVersion param.Opt[string] `json:"app_version,omitzero"`
	// Geographic region or data center.
	SourceRegion param.Opt[string] `json:"source_region,omitzero"`
	// Sub tenant of the user or organization
	SubTenant param.Opt[string] `json:"sub_tenant,omitzero"`
	// Each item groups tools for a given MCP server.
	McpTools    []AIGuardGuardChatCompletionsParamsExtraInfoMcpTool `json:"mcp_tools,omitzero"`
	ExtraFields map[string]any                                      `json:"-"`
	// contains filtered or unexported fields
}

(AIDR) Logging schema.

func (AIGuardGuardChatCompletionsParamsExtraInfo) MarshalJSON

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

func (*AIGuardGuardChatCompletionsParamsExtraInfo) UnmarshalJSON

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

type AIGuardGuardChatCompletionsParamsExtraInfoMcpTool

type AIGuardGuardChatCompletionsParamsExtraInfoMcpTool struct {
	// MCP server name
	ServerName string   `json:"server_name,required"`
	Tools      []string `json:"tools,omitzero,required"`
	// contains filtered or unexported fields
}

The properties ServerName, Tools are required.

func (AIGuardGuardChatCompletionsParamsExtraInfoMcpTool) MarshalJSON

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

func (*AIGuardGuardChatCompletionsParamsExtraInfoMcpTool) UnmarshalJSON

type AIGuardGuardChatCompletionsResponse

type AIGuardGuardChatCompletionsResponse struct {
	// A unique identifier assigned to each request made to the API. It is used to
	// track and identify a specific request and its associated data. The `request_id`
	// can be helpful for troubleshooting, auditing, and tracing the flow of requests
	// within the system. It allows users to reference and retrieve information related
	// to a particular request, such as the response, parameters, and raw data
	// associated with that specific request.
	//
	// “`
	// "request_id":"prq_x6fdiizbon6j3bsdvnpmwxsz2aan7fqd"
	// “`
	RequestID string `json:"request_id,required"`
	// The timestamp indicates the exact moment when a request is made to the API. It
	// represents the date and time at which the request was initiated by the client.
	// The `request_time` is useful for tracking and analyzing the timing of requests,
	// measuring response times, and monitoring performance metrics. It allows users to
	// determine the duration between the request initiation and the corresponding
	// response, aiding in the assessment of API performance and latency.
	//
	// “`
	// "request_time":"2022-09-21T17:24:33.105Z"
	// “`
	RequestTime time.Time `json:"request_time,required" format:"date-time"`
	// Duration it takes for the API to process a request and generate a response. It
	// represents the elapsed time from when the request is received by the API to when
	// the corresponding response is returned to the client.
	//
	// “`
	// "response_time":"2022-09-21T17:24:34.007Z"
	// “`
	ResponseTime time.Time                                 `json:"response_time,required" format:"date-time"`
	Result       AIGuardGuardChatCompletionsResponseResult `json:"result,required"`
	// It represents the status or outcome of the API request made for IP information.
	// It indicates the current state or condition of the request and provides
	// information on the success or failure of the request.
	//
	// “`
	// "status":"success"
	// “`
	//
	// Any of "Success".
	Status AIGuardGuardChatCompletionsResponseStatus `json:"status,required"`
	// Provides a concise and brief overview of the purpose or primary objective of the
	// API endpoint. It serves as a high-level summary or description of the
	// functionality or feature offered by the endpoint.
	Summary string `json:"summary"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		RequestID    respjson.Field
		RequestTime  respjson.Field
		ResponseTime respjson.Field
		Result       respjson.Field
		Status       respjson.Field
		Summary      respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponse) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponse) UnmarshalJSON

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

type AIGuardGuardChatCompletionsResponseResult

type AIGuardGuardChatCompletionsResponseResult struct {
	// Result of the policy analyzing and input prompt.
	Detectors AIGuardGuardChatCompletionsResponseResultDetectors `json:"detectors,required"`
	// Result of the recipe evaluating configured rules
	AccessRules any `json:"access_rules"`
	// Whether or not the prompt triggered a block detection.
	Blocked bool `json:"blocked"`
	// If an FPE redaction method returned results, this will be the context passed to
	// unredact.
	FpeContext string `json:"fpe_context" format:"base64"`
	// Updated structured prompt.
	GuardOutput any `json:"guard_output"`
	// The Policy that was used.
	Policy string `json:"policy"`
	// Whether or not the original input was transformed.
	Transformed bool `json:"transformed"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Detectors   respjson.Field
		AccessRules respjson.Field
		Blocked     respjson.Field
		FpeContext  respjson.Field
		GuardOutput respjson.Field
		Policy      respjson.Field
		Transformed respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResult) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResult) UnmarshalJSON

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

type AIGuardGuardChatCompletionsResponseResultDetectors

type AIGuardGuardChatCompletionsResponseResultDetectors struct {
	Code                     AIGuardGuardChatCompletionsResponseResultDetectorsCode                     `json:"code"`
	Competitors              AIGuardGuardChatCompletionsResponseResultDetectorsCompetitors              `json:"competitors"`
	ConfidentialAndPiiEntity AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntity `json:"confidential_and_pii_entity"`
	CustomEntity             AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntity             `json:"custom_entity"`
	Language                 AIGuardGuardChatCompletionsResponseResultDetectorsLanguage                 `json:"language"`
	MaliciousEntity          AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntity          `json:"malicious_entity"`
	MaliciousPrompt          AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPrompt          `json:"malicious_prompt"`
	SecretAndKeyEntity       AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntity       `json:"secret_and_key_entity"`
	Topic                    AIGuardGuardChatCompletionsResponseResultDetectorsTopic                    `json:"topic"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code                     respjson.Field
		Competitors              respjson.Field
		ConfidentialAndPiiEntity respjson.Field
		CustomEntity             respjson.Field
		Language                 respjson.Field
		MaliciousEntity          respjson.Field
		MaliciousPrompt          respjson.Field
		SecretAndKeyEntity       respjson.Field
		Topic                    respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Result of the policy analyzing and input prompt.

func (AIGuardGuardChatCompletionsResponseResultDetectors) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectors) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCode

type AIGuardGuardChatCompletionsResponseResultDetectorsCode struct {
	// Details about the detected code.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsCodeData `json:"data"`
	// Whether or not the Code was detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsCode) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCode) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCodeData

type AIGuardGuardChatCompletionsResponseResultDetectorsCodeData struct {
	// The action taken by this Detector
	Action   string `json:"action"`
	Language string `json:"language"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Language    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected code.

func (AIGuardGuardChatCompletionsResponseResultDetectorsCodeData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCodeData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCompetitors

type AIGuardGuardChatCompletionsResponseResultDetectorsCompetitors struct {
	// Details about the detected entities.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsCompetitorsData `json:"data"`
	// Whether or not the Competitors were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsCompetitors) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCompetitors) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCompetitorsData

type AIGuardGuardChatCompletionsResponseResultDetectorsCompetitorsData struct {
	// The action taken by this Detector
	Action string `json:"action"`
	// Detected entities.
	Entities []string `json:"entities"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Entities    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected entities.

func (AIGuardGuardChatCompletionsResponseResultDetectorsCompetitorsData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCompetitorsData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntity struct {
	// Details about the detected entities.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityData `json:"data"`
	// Whether or not the PII Entities were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityData

type AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityData struct {
	// Detected redaction rules.
	Entities []AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityDataEntity `json:"entities"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Entities    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected entities.

func (AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityDataEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityDataEntity struct {
	// The action taken on this Entity
	Action   string `json:"action,required"`
	Type     string `json:"type,required"`
	Value    string `json:"value,required"`
	StartPos int64  `json:"start_pos"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		StartPos    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityDataEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsConfidentialAndPiiEntityDataEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntity struct {
	// Details about the detected entities.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityData `json:"data"`
	// Whether or not the Custom Entities were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityData

type AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityData struct {
	// Detected redaction rules.
	Entities []AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityDataEntity `json:"entities"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Entities    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected entities.

func (AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityDataEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityDataEntity struct {
	// The action taken on this Entity
	Action   string `json:"action,required"`
	Type     string `json:"type,required"`
	Value    string `json:"value,required"`
	StartPos int64  `json:"start_pos"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		StartPos    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityDataEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsCustomEntityDataEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsLanguage

type AIGuardGuardChatCompletionsResponseResultDetectorsLanguage struct {
	// Details about the detected languages.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsLanguageData `json:"data"`
	// Whether or not the Languages were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsLanguage) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsLanguage) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsLanguageData

type AIGuardGuardChatCompletionsResponseResultDetectorsLanguageData struct {
	// The action taken by this Detector
	Action   string `json:"action"`
	Language string `json:"language"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Language    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected languages.

func (AIGuardGuardChatCompletionsResponseResultDetectorsLanguageData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsLanguageData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntity struct {
	// Details about the detected entities.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityData `json:"data"`
	// Whether or not the Malicious Entities were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityData

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityData struct {
	// Detected harmful items.
	Entities []AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityDataEntity `json:"entities"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Entities    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected entities.

func (AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityDataEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityDataEntity struct {
	Type     string `json:"type,required"`
	Value    string `json:"value,required"`
	Raw      any    `json:"raw"`
	StartPos int64  `json:"start_pos"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Value       respjson.Field
		Raw         respjson.Field
		StartPos    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityDataEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousEntityDataEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPrompt

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPrompt struct {
	// Details about the analyzers.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptData `json:"data"`
	// Whether or not the Malicious Prompt was detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPrompt) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPrompt) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptData

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptData struct {
	// The action taken by this Detector
	Action string `json:"action"`
	// Triggered prompt injection analyzers.
	AnalyzerResponses []AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptDataAnalyzerResponse `json:"analyzer_responses"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action            respjson.Field
		AnalyzerResponses respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the analyzers.

func (AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptDataAnalyzerResponse

type AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptDataAnalyzerResponse struct {
	Analyzer   string  `json:"analyzer,required"`
	Confidence float64 `json:"confidence,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Analyzer    respjson.Field
		Confidence  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptDataAnalyzerResponse) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsMaliciousPromptDataAnalyzerResponse) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntity struct {
	// Details about the detected entities.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityData `json:"data"`
	// Whether or not the Secret Entities were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityData

type AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityData struct {
	// Detected redaction rules.
	Entities []AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityDataEntity `json:"entities"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Entities    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected entities.

func (AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityDataEntity

type AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityDataEntity struct {
	// The action taken on this Entity
	Action   string `json:"action,required"`
	Type     string `json:"type,required"`
	Value    string `json:"value,required"`
	StartPos int64  `json:"start_pos"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		StartPos    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityDataEntity) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsSecretAndKeyEntityDataEntity) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsTopic

type AIGuardGuardChatCompletionsResponseResultDetectorsTopic struct {
	// Details about the detected topics.
	Data AIGuardGuardChatCompletionsResponseResultDetectorsTopicData `json:"data"`
	// Whether or not the Topics were detected.
	Detected bool `json:"detected"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Detected    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsTopic) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsTopic) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsTopicData

type AIGuardGuardChatCompletionsResponseResultDetectorsTopicData struct {
	// The action taken by this Detector
	Action string `json:"action"`
	// List of topics detected
	Topics []AIGuardGuardChatCompletionsResponseResultDetectorsTopicDataTopic `json:"topics"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Action      respjson.Field
		Topics      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the detected topics.

func (AIGuardGuardChatCompletionsResponseResultDetectorsTopicData) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsTopicData) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseResultDetectorsTopicDataTopic

type AIGuardGuardChatCompletionsResponseResultDetectorsTopicDataTopic struct {
	Confidence float64 `json:"confidence,required"`
	Topic      string  `json:"topic,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Confidence  respjson.Field
		Topic       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardGuardChatCompletionsResponseResultDetectorsTopicDataTopic) RawJSON

Returns the unmodified JSON received from the API

func (*AIGuardGuardChatCompletionsResponseResultDetectorsTopicDataTopic) UnmarshalJSON

type AIGuardGuardChatCompletionsResponseStatus

type AIGuardGuardChatCompletionsResponseStatus string

It represents the status or outcome of the API request made for IP information. It indicates the current state or condition of the request and provides information on the success or failure of the request.

``` "status":"success" ```

const (
	AIGuardGuardChatCompletionsResponseStatusSuccess AIGuardGuardChatCompletionsResponseStatus = "Success"
)

type AIGuardService

type AIGuardService struct {
	Options     []option.RequestOption
	ServiceName string
}

AIGuardService contains methods and other services that help with interacting with the AIDR 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 NewAIGuardService method instead.

func NewAIGuardService

func NewAIGuardService(opts ...option.RequestOption) (r AIGuardService)

NewAIGuardService 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 (*AIGuardService) GetAsyncRequest

func (r *AIGuardService) GetAsyncRequest(ctx context.Context, requestID string, opts ...option.RequestOption) (res *AIGuardGetAsyncRequestResponse, err error)

Will retrieve the result, or will return 202 if the original request is still in progress

func (*AIGuardService) GuardChatCompletions

Analyze and redact content to avoid manipulation of the model, addition of malicious content, and other undesirable data transfers.

func (*AIGuardService) Unredact added in v1.2.0

Decrypt or unredact fpe redactions

type AIGuardUnredactParams added in v1.2.0

type AIGuardUnredactParams struct {
	// FPE context used to decrypt and unredact data
	FpeContext string `json:"fpe_context,required" format:"base64"`
	// Data to unredact
	RedactedData any `json:"redacted_data,omitzero,required"`
	// contains filtered or unexported fields
}

func (AIGuardUnredactParams) MarshalJSON added in v1.2.0

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

func (*AIGuardUnredactParams) UnmarshalJSON added in v1.2.0

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

type AIGuardUnredactResponse added in v1.2.0

type AIGuardUnredactResponse struct {
	Result AIGuardUnredactResponseResult `json:"result"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
	PangeaResponse
}

func (AIGuardUnredactResponse) RawJSON added in v1.2.0

func (r AIGuardUnredactResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AIGuardUnredactResponse) UnmarshalJSON added in v1.2.0

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

type AIGuardUnredactResponseResult added in v1.2.0

type AIGuardUnredactResponseResult struct {
	// The unredacted data
	Data any `json:"data,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AIGuardUnredactResponseResult) RawJSON added in v1.2.0

Returns the unmodified JSON received from the API

func (*AIGuardUnredactResponseResult) UnmarshalJSON added in v1.2.0

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

type Client

type Client struct {
	Options []option.RequestOption
	AIGuard AIGuardService
}

Client creates a struct with services and top level methods that help with interacting with the AIDR 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 (AIDR_API_TOKEN, AIDR_BASE_URL_TEMPLATE). 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, 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, path string, params, 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, 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) Patch

func (r *Client) Patch(ctx context.Context, path string, params, 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, 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, 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 Error

type Error = apierror.Error

type PangeaResponse added in v1.2.0

type PangeaResponse struct {
	// A unique identifier assigned to each request made to the API. It is used to
	// track and identify a specific request and its associated data. The `request_id`
	// can be helpful for troubleshooting, auditing, and tracing the flow of requests
	// within the system. It allows users to reference and retrieve information related
	// to a particular request, such as the response, parameters, and raw data
	// associated with that specific request.
	//
	// “`
	// "request_id":"prq_x6fdiizbon6j3bsdvnpmwxsz2aan7fqd"
	// “`
	RequestID string `json:"request_id,required"`
	// The timestamp indicates the exact moment when a request is made to the API. It
	// represents the date and time at which the request was initiated by the client.
	// The `request_time` is useful for tracking and analyzing the timing of requests,
	// measuring response times, and monitoring performance metrics. It allows users to
	// determine the duration between the request initiation and the corresponding
	// response, aiding in the assessment of API performance and latency.
	//
	// “`
	// "request_time":"2022-09-21T17:24:33.105Z"
	// “`
	RequestTime time.Time `json:"request_time,required" format:"date-time"`
	// Duration it takes for the API to process a request and generate a response. It
	// represents the elapsed time from when the request is received by the API to when
	// the corresponding response is returned to the client.
	//
	// “`
	// "response_time":"2022-09-21T17:24:34.007Z"
	// “`
	ResponseTime time.Time `json:"response_time,required" format:"date-time"`
	// It represents the status or outcome of the API request made for IP information.
	// It indicates the current state or condition of the request and provides
	// information on the success or failure of the request.
	//
	// “`
	// "status":"success"
	// “`
	Status string `json:"status,required"`
	// Provides a concise and brief overview of the purpose or primary objective of the
	// API endpoint. It serves as a high-level summary or description of the
	// functionality or feature offered by the endpoint.
	Summary string `json:"summary"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		RequestID    respjson.Field
		RequestTime  respjson.Field
		ResponseTime respjson.Field
		Status       respjson.Field
		Summary      respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Pangea standard response schema

func (PangeaResponse) RawJSON added in v1.2.0

func (r PangeaResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*PangeaResponse) UnmarshalJSON added in v1.2.0

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

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

Jump to

Keyboard shortcuts

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