### Complete Agent Session Setup Example Source: https://docs.smallest.ai/atoms/developer-guide/get-started/core-concepts/sessions.md This example demonstrates initializing nodes, building the graph with add_node and add_edge, registering event hooks, and launching the session with start() and wait_until_complete(). ```python from smallestai.atoms.agent.session import AgentSession from smallestai.atoms.agent.server import AtomsApp async def setup(session: AgentSession): # 1. Initialize Nodes agent = SalesAgent() tracker = StatsTracker() # 2. Build Graph session.add_node(tracker) session.add_node(agent) session.add_edge(tracker, agent) # Events go Tracker -> Agent # 3. Register Hooks @session.on_event("system.control.interrupt") async def on_interrupt(session, event): print("User interrupted the agent!") # 4. Launch await session.start() await session.wait_until_complete() if __name__ == "__main__": app = AtomsApp(setup_handler=setup) app.run() ``` -------------------------------- ### Complete Example: Sales Call Analytics Setup Source: https://docs.smallest.ai/atoms/developer-guide/operate/analytics/post-call-analytics.md Demonstrates the setup for a sales call analytics scenario, including agent creation and importing necessary modules. This is a starting point for more complex analytics configurations. ```python import time from smallestai.atoms import AtomsClient from smallestai.atoms.call import Call from smallestai.atoms.audience import Audience from smallestai.atoms.campaign import Campaign client = AtomsClient() call = Call() audience = Audience() campaign = Campaign() # 1. Create agent agent = client.new_agent( name=f"Sales Agent {int(time.time())}", prompt="You are a sales agent. Ask if interested and get their name.", description="Testing disposition metrics" ) agent_id = agent.data ``` -------------------------------- ### Install Dependencies for Vonage Example Source: https://docs.smallest.ai/atoms/integrations/vonage.md Install all necessary Python packages required to run the Vonage telephony example. ```bash pip install -r requirements.txt ``` -------------------------------- ### Go SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using Go. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Atoms Agent Quickstart Class (Swift) Source: https://docs.smallest.ai/atoms/atoms-platform/integrate/mobile-integrations/i-os-swift.md A basic class structure for integrating with the Atoms agent. It includes properties for API key, agent ID, sample rate, WebSocket task, and audio engine components. The `start` function initiates the audio session, WebSocket connection, playback setup, and microphone tap, while `stop` cleans up resources. ```swift import AVFoundation import Foundation final class AtomsAgent: NSObject { private let apiKey: String private let agentId: String private let sampleRate: Double = 24_000 private var webSocketTask: URLSessionWebSocketTask? private let audioEngine = AVAudioEngine() private var playerNode: AVAudioPlayerNode? private var playerFormat: AVAudioFormat? init(apiKey: String, agentId: String) { self.apiKey = apiKey self.agentId = agentId } func start() async throws { try configureAudioSession() connectWebSocket() try setupPlayback() try startMicrophoneTap() } func stop() { audioEngine.stop() webSocketTask?.cancel(with: .goingAway, reason: nil) } } ``` -------------------------------- ### List Agent Versions (PHP) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/list-published-versions.md This PHP example uses GuzzleHttp to perform the GET request. Make sure to install Guzzle via Composer. ```php request('GET', 'https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Swift SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using Swift. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Ruby SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using Ruby. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```ruby require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Java SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using Java and Unirest. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Clone Cookbook Repository Source: https://docs.smallest.ai/atoms/developer-guide/examples/examples.md Clone the Smallest AI cookbook repository to access example projects. Navigate to the specific example directory and install dependencies. ```bash # Clone the cookbook git clone https://github.com/smallest-inc/cookbook cd cookbook/voice-agents/ # Install dependencies pip install -e . # Set environment variables export OPENAI_API_KEY="your-key" # Run locally python app.py # Test with CLI (in another terminal) smallestai agent chat ``` -------------------------------- ### Get Compliance Requirements (Go) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-requirements.md This Go example demonstrates how to make an HTTP GET request to fetch compliance requirements, including setting necessary headers and reading the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/compliance/requirements?countryIso=US&numberType=mobile&userType=individual" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get a Campaign using Go HTTP Client Source: https://docs.smallest.ai/atoms/api-reference/api-reference/campaigns/get-a-campaign.md Make a direct HTTP GET request to the campaign endpoint. This example shows how to set up the request, add the Authorization header, and read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/campaign/id" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Agent Draft Detail in Go Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-drafts/get-draft-detail.md This Go example demonstrates making an HTTP GET request using the standard `net/http` package. Remember to handle potential errors. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/drafts/draftId" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Agent Version Detail in Go Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/get-version-detail.md This Go example shows how to perform an HTTP GET request to fetch agent version details. Replace `` with your authentication token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/versionId" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Agent Draft Diff - PHP Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-drafts/get-draft-diff.md A PHP example using GuzzleHttp to get agent draft differences. Ensure you have Guzzle installed and replace `` with your authorization token. ```php request('GET', 'https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/drafts/draftId/diff', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Quickstart: Connect to Agent with TypeScript Source: https://docs.smallest.ai/atoms/atoms-platform/integrate/web-socket-sdk.md Initialize the agent, set up event listeners for session status and agent speech, and connect to the agent. Microphone capture starts automatically upon connection. ```typescript import { AtomsAgent } from "@smallest-ai/agent-sdk"; const agent = new AtomsAgent({ apiKey: "sk_...", // Smallest API key agentId: "...", // Agent ID }); agent.on("session_started", (e) => { console.log("Session started:", e.session_id, e.call_id); }); agent.on("agent_start_talking", () => console.log("Agent speaking")); agent.on("agent_stop_talking", () => console.log("Agent stopped")); agent.on("error", (e) => console.error(`[${e.code}] ${e.message}`)); await agent.connect(); // Microphone capture starts automatically. Speak, and the agent replies // through the default audio output. Call agent.disconnect() when done. ``` -------------------------------- ### Quickstart: Connect to Agent with CDN Source: https://docs.smallest.ai/atoms/atoms-platform/integrate/web-socket-sdk.md Initialize the agent using the global `AtomsSdk` object and connect. This is the equivalent of the TypeScript quickstart when using the SDK via a CDN. ```html ``` -------------------------------- ### Get Compliance Requirements (PHP) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-requirements.md Using GuzzleHttp in PHP to fetch compliance requirements. This example assumes you have GuzzleHttp installed via Composer. ```php request('GET', 'https://api.smallest.ai/atoms/v1/compliance/requirements?countryIso=US&numberType=mobile&userType=individual', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### List Agent Versions (Go) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/list-published-versions.md This Go example demonstrates making an HTTP GET request using the `net/http` package. It includes setting headers and reading the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Agent Draft Detail in PHP Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-drafts/get-draft-detail.md Example using Guzzle HTTP client in PHP to fetch draft details. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/drafts/draftId', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Create Knowledge Base with Go HTTP Request Source: https://docs.smallest.ai/atoms/api-reference/api-reference/knowledge-base/create-a-knowledge-base.md This example demonstrates making a direct HTTP POST request to create a knowledge base. It includes setting the Authorization and Content-Type headers. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/knowledgebase" payload := strings.NewReader("{\n \"name\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Compliance Status with PHP (Guzzle) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md This PHP example uses the Guzzle HTTP client to retrieve compliance status. Ensure you have Guzzle installed via Composer and replace `` with your API key. ```php request('GET', 'https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Set up AtomsApp with an Agent Source: https://docs.smallest.ai/atoms/developer-guide/get-started/quickstart.md Wire up `AtomsApp` with a `setup_handler` that adds your custom agent to the session and starts the application. This file serves as the entry point for your agent. ```python from smallestai.atoms.agent.server import AtomsApp from smallestai.atoms.agent.session import AgentSession from my_agent import MyAgent async def on_start(session: AgentSession): session.add_node(MyAgent()) await session.start() await session.wait_until_complete() if __name__ == "__main__": app = AtomsApp(setup_handler=on_start) app.run() ``` -------------------------------- ### Start Campaign with Python SDK Source: https://docs.smallest.ai/atoms/api-reference/api-reference/campaigns/start-a-campaign.md Initiate a campaign using the SmallestAI client. Replace 'YOUR_TOKEN_HERE' with your valid API token. ```python from smallest_ai import SmallestAI client = SmallestAI( token="YOUR_TOKEN_HERE", ) client.atoms.campaigns.start_a_campaign( id="id", ) ``` -------------------------------- ### Create Webhook Subscription (Go) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/create-webhook-subscriptions-for-an-agent.md This Go example demonstrates how to create a webhook subscription using direct HTTP requests. It includes setting the correct URL, payload, and headers. Replace '' with your actual API token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/agentId/webhook-subscriptions" payload := strings.NewReader("{\n \"eventTypes\": [\n \"pre-conversation\"\n ],\n \"webhookId\": \"60d0fe4f5311236168a109ca\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get All Knowledge Bases via HTTP Request (Swift) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/knowledge-base/get-all-knowledge-bases.md Demonstrates making an HTTP GET request using Swift's Foundation framework. Includes setting up headers and handling the response. ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/knowledgebase")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### C# SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using C# and RestSharp. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```csharp using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Create and Start Campaign Source: https://docs.smallest.ai/atoms/developer-guide/operate/analytics/post-call-analytics.md Create an audience and a campaign, then start the campaign to initiate calls. This sets up the environment for making calls that will be analyzed. ```python phones = client.get_phone_numbers() phone_id = phones["data"][0]["_id"] aud = audience.create( name=f"Test Audience {int(time.time())}", phone_numbers=["+916366821717"], names=[("Test", "User")] ) audience_id = aud["data"]["_id"] camp = campaign.create( name=f"Analytics Test {int(time.time())}", agent_id=agent_id, audience_id=audience_id, phone_ids=[phone_id] ) campaign_id = camp["data"]["_id"] campaign.start(campaign_id) print("Call in progress...") ``` -------------------------------- ### PHP SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using PHP and Guzzle. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```php request('GET', 'https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Create Agent Draft with Go Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-drafts/create-a-draft.md This Go example demonstrates creating an agent draft using the standard net/http package. Remember to replace `` with your API key. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/drafts" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Install SDK via npm, pnpm, or yarn Source: https://docs.smallest.ai/atoms/atoms-platform/integrate/web-socket-sdk.md Install the SDK using your preferred package manager. ```bash npm install @smallest-ai/agent-sdk ``` ```bash pnpm add @smallest-ai/agent-sdk ``` ```bash yarn add @smallest-ai/agent-sdk ``` -------------------------------- ### JavaScript SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using JavaScript and the fetch API. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```javascript const url = 'https://api.smallest.ai/atoms/v1/compliance/status?countryIso=US&numberType=mobile&userType=individual'; const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Python SDK Example Source: https://docs.smallest.ai/atoms/api-reference/api-reference/compliance/get-compliance-status.md Example of how to get compliance status using Python and the requests library. ```APIDOC ## GET /atoms/v1/compliance/status ### Description Retrieves the compliance status for a given set of parameters. ### Method GET ### Endpoint https://api.smallest.ai/atoms/v1/compliance/status ### Query Parameters - **countryIso** (string) - Required - The ISO country code. - **numberType** (string) - Required - The type of number (e.g., 'mobile'). - **userType** (string) - Required - The type of user (e.g., 'individual'). ### Request Example ```python import requests url = "https://api.smallest.ai/atoms/v1/compliance/status" querystring = {"countryIso":"US","numberType":"mobile","userType":"individual"} payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.get(url, json=payload, headers=headers, params=querystring) print(response.json()) ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Get a Campaign using Ruby Net::HTTP Source: https://docs.smallest.ai/atoms/api-reference/api-reference/campaigns/get-a-campaign.md This example demonstrates making a GET request using Ruby's built-in Net::HTTP library. It includes setting up the URL, SSL, headers, and sending the request. ```ruby require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/campaign/id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Retrieve All Agents (Swift) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-all-agents.md Example of how to get all agents using a direct HTTP GET request. ```APIDOC ## Get All Agents (Swift) ### Description Retrieves a list of all agents available in the system via an HTTP GET request. ### Method GET ### Endpoint `https://api.smallest.ai/atoms/v1/agent` ### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/agent")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ``` -------------------------------- ### Proper Agent Session Setup Source: https://docs.smallest.ai/atoms/developer-guide/operate/testing-debugging/common-issues.md Ensure your agent session is set up correctly by including `session.start()` and `session.wait_until_complete()` to prevent unexpected session endings. ```python async def setup(session: AgentSession): agent = MyAgent() session.add_node(agent) await session.start() await session.wait_until_complete() # Do not forget this ``` -------------------------------- ### Retrieve All Agents (C#) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-all-agents.md Example of how to get all agents using a direct HTTP GET request. ```APIDOC ## Get All Agents (C#) ### Description Retrieves a list of all agents available in the system via an HTTP GET request. ### Method GET ### Endpoint `https://api.smallest.ai/atoms/v1/agent` ### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```csharp using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/agent"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ``` -------------------------------- ### Complete Support Agent Example Source: https://docs.smallest.ai/atoms/developer-guide/build/agents/tools/built-in-tools.md This example demonstrates a complete support agent integrating with an LLM (OpenAIClient) and utilizing tool registration for actions like 'get_order_status' and 'end_call'. It handles LLM responses, tool execution, and context management. ```python import os from smallestai.atoms.agent.nodes import OutputAgentNode from smallestai.atoms.agent.clients.openai import OpenAIClient from smallestai.atoms.agent.tools import ToolRegistry, function_tool from smallestai.atoms.agent.events import SDKAgentEndCallEvent class SupportAgent(OutputAgentNode): def __init__(self): super().__init__(name="support-agent") self.llm = OpenAIClient(model="gpt-4o-mini") self.tool_registry = ToolRegistry() self.tool_registry.discover(self) self.context.add_message({ "role": "system", "content": "You are a support agent. Help users with their questions. " "Use end_call when they're done." }) @function_tool() def get_order_status(self, order_id: str): """Look up an order's status. Args: order_id: Order ID like "ORD-12345" """ # Your implementation return {"status": "shipped", "eta": "Tomorrow"} @function_tool() async def end_call(self): """End the call when the user says goodbye.""" await self.send_event(SDKAgentEndCallEvent()) return None async def generate_response(self): response = await self.llm.chat( messages=self.context.messages, stream=True, tools=self.tool_registry.get_schemas() ) tool_calls = [] async for chunk in response: if chunk.content: yield chunk.content if chunk.tool_calls: tool_calls.extend(chunk.tool_calls) if tool_calls: results = await self.tool_registry.execute(tool_calls=tool_calls, parallel=True) self.context.add_messages([ { "role": "assistant", "content": "", "tool_calls": [ {"id": tc.id, "type": "function", "function": {"name": tc.name, "arguments": str(tc.arguments)}} for tc in tool_calls ] }, *[{"role": "tool", "tool_call_id": tc.id, "content": result.content} for tc, result in zip(tool_calls, results)] ]) final = await self.llm.chat(messages=self.context.messages, stream=True) async for chunk in final: if chunk.content: yield chunk.content ``` -------------------------------- ### Create Knowledge Base with Python SDK Source: https://docs.smallest.ai/atoms/api-reference/api-reference/knowledge-base/create-a-knowledge-base.md Instantiate the SmallestAI client with your token and call the create_a_knowledge_base method. Remember to substitute 'YOUR_TOKEN_HERE'. ```python from smallest_ai import SmallestAI client = SmallestAI( token="YOUR_TOKEN_HERE", ) client.atoms.knowledge_base.create_a_knowledge_base( name="string", ) ``` -------------------------------- ### Retrieve All Agents (PHP) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-all-agents.md Example of how to get all agents using a direct HTTP GET request. ```APIDOC ## Get All Agents (PHP) ### Description Retrieves a list of all agents available in the system via an HTTP GET request. ### Method GET ### Endpoint `https://api.smallest.ai/atoms/v1/agent` ### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```php request('GET', 'https://api.smallest.ai/atoms/v1/agent', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ``` -------------------------------- ### Verify CLI Installation Source: https://docs.smallest.ai/atoms/developer-guide/get-started/cli.md Check if the CLI is installed correctly by running the help command. ```bash smallestai --help ``` -------------------------------- ### Retrieve All Agents (Java) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-all-agents.md Example of how to get all agents using a direct HTTP GET request. ```APIDOC ## Get All Agents (Java) ### Description Retrieves a list of all agents available in the system via an HTTP GET request. ### Method GET ### Endpoint `https://api.smallest.ai/atoms/v1/agent` ### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.smallest.ai/atoms/v1/agent") .header("Authorization", "Bearer ") .asString(); ``` ``` -------------------------------- ### Compare Agent Version Metrics in Go Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/compare-metrics-between-two-versions.md This Go example shows how to construct an HTTP GET request with custom headers and a JSON payload. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=5f8d0d55b54764421b7156c1&versionB=5f8d0d55b54764421b7156c2&dateFrom=2024-05-01T00%3A00%3A00Z&dateTo=2024-05-15T23%3A59%3A59Z" payload := strings.NewReader("{\n \"id\": \"60d0fe4f5311236168a109ca\"\n}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Retrieve All Agents (Ruby) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-all-agents.md Example of how to get all agents using a direct HTTP GET request. ```APIDOC ## Get All Agents (Ruby) ### Description Retrieves a list of all agents available in the system via an HTTP GET request. ### Method GET ### Endpoint `https://api.smallest.ai/atoms/v1/agent` ### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```ruby require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/agent") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ``` -------------------------------- ### Retrieve All Agents (Go) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-all-agents.md Example of how to get all agents using a direct HTTP GET request. ```APIDOC ## Get All Agents (Go) ### Description Retrieves a list of all agents available in the system via an HTTP GET request. ### Method GET ### Endpoint `https://api.smallest.ai/atoms/v1/agent` ### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ``` -------------------------------- ### Run FastAPI Application Source: https://docs.smallest.ai/atoms/integrations/plivo.md Start the FastAPI server that handles audio streaming. Remember to update the ngrok URL and any necessary paths in the script before execution. ```bash python plivo_example/plivo_app.py ``` -------------------------------- ### Get Audience Members via HTTP GET Request (C#) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/audience/get-audience-members.md Example in C# using RestSharp to execute a GET request for audience members, showing how to set the Authorization header. ```csharp using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/audience/60d0fe4f5311236168a109ca/members"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Audience Members via HTTP GET Request (Java) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/audience/get-audience-members.md A Java example using Unirest to perform an HTTP GET request for audience members, demonstrating how to add the Authorization header. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.smallest.ai/atoms/v1/audience/60d0fe4f5311236168a109ca/members") .header("Authorization", "Bearer ") .asString(); ``` -------------------------------- ### Start Campaign via HTTP POST (C#) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/campaigns/start-a-campaign.md Employ RestSharp to execute a POST request for starting a campaign. Include the Authorization header with your token. ```csharp using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/campaign/id/start"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Activate Agent Version with Go Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/activate-a-version.md This Go example demonstrates how to make a PATCH request using the standard net/http package to activate an agent version. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/versionId/activate" payload := strings.NewReader("{}") req, _ := http.NewRequest("PATCH", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Audience Members via HTTP GET Request (Ruby) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/audience/get-audience-members.md This Ruby example shows how to construct an HTTP GET request to retrieve audience members, including setting the Authorization header. ```ruby require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/audience/60d0fe4f5311236168a109ca/members") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Create a Knowledge Base Source: https://docs.smallest.ai/atoms/developer-guide/build/knowledge-base/usage.md Use the `kb.create` method to initialize a new knowledge base with a name and optional description. The response contains the KB ID required for subsequent operations. ```python from smallestai.atoms.kb import KB from smallestai.atoms import AtomsClient # Initialize separate managers kb = KB() client = AtomsClient() # Create KB response = kb.create( name="Product Documentation", description="Technical specs and troubleshooting guides" ) kb_id = response["data"] ``` ```json { "status": true, "data": "696ddd64b9f099f0679fdb41" } ``` -------------------------------- ### Get Agent Workflow using SDK Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agents/get-agent-workflow.md Examples of how to get an agent's workflow using the SmallestAI client library in TypeScript and Python. ```APIDOC ## Get Agent Workflow using SDK ### Description This section shows how to retrieve an agent's workflow using the official SDKs. ### TypeScript Example ```typescript import { SmallestAIClient } from "smallest-ai"; async function main() { const client = new SmallestAIClient({ token: "YOUR_TOKEN_HERE", }); await client.atoms.agents.getAgentWorkflow("id"); } main(); ``` ### Python Example ```python from smallest_ai import SmallestAI client = SmallestAI( token="YOUR_TOKEN_HERE", ) client.atoms.agents.get_agent_workflow( id="id", ) ``` ``` -------------------------------- ### Get Audience Members via HTTP GET Request (Go) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/audience/get-audience-members.md Directly make an HTTP GET request to the audience members endpoint. This example demonstrates setting the Authorization header with a Bearer token. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/audience/60d0fe4f5311236168a109ca/members" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### List Agent Versions (Swift) Source: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/list-published-versions.md This Swift example uses `URLSession` to make the GET request. It demonstrates setting up the `NSMutableURLRequest` with headers and the request body. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Example API Request Source: https://docs.smallest.ai/atoms/atoms-platform/features/api-calls.md Demonstrates a GET request to an example API endpoint, utilizing a dynamic customer ID from the caller's phone number. ```http GET https://api.example.com/customers/{{caller_phone}} ``` -------------------------------- ### Run the agent server Source: https://docs.smallest.ai/atoms/developer-guide/operate/testing-debugging/common-issues.md Start your agent by running the main Python script. ```bash python agent.py ```