# Welcome to Agent Orbit

### Getting Started with Agent Orbit

Agent Orbit enables you to run Python-based agents in the cloud effortlessly, without worrying about server management. Agents can be executed on-demand or scheduled at specific intervals using the intuitive UI, a REST API, or the Python SDK.

During execution, every agent has access to its dedicated and persistent storage, allowing it to store and retrieve data seamlessly.

***

#### Create Your First Agent

You can create agents directly from the **Agent Orbit Dashboard** or programmatically via the REST API or Python SDK. This guide focuses on using the dashboard for simplicity.

An agent consists of three core elements:

1. **Script** – Your Python code that runs during execution.
2. **Requirements** – A list of Python packages your script depends on.
3. **Environment Variables** – External variables accessible by your script during execution.

Of these, **Script** is the only mandatory component.

***

***

## **Agent Orbit**: Cloud-Based Python Agents Made Simple

With Agent Orbit, you can execute Python agents in the cloud without managing servers. Whether you want to schedule tasks, run them manually, or programmatically trigger them via REST API or Python SDK, Agent Orbit has you covered.

#### **Key Features**

* **Flexible Execution**: Schedule agents or trigger them manually.
* **Persistent Storage**: Each agent gets dedicated storage for data retrieval and storage.
* **Seamless Integration**: Use the UI, REST API, or Python SDK to interact with your agents.

***

### **Step 1: Create an Agent**

Creating agents is easy! You can do it through:

* **Dashboard**: Visit dashboard.agentorbit.ai/create
* **REST API**: Programmatically create agents via HTTP requests.
* **Python SDK**: Automate agent creation in Python scripts.

Each agent requires:

* **Script**: Your Python code (required).
* **Dependencies**: Python packages your script needs (optional).
* **Environment Variables**: Variables accessible during execution (optional).

***

#### **Writing Your Script**

Every agent needs a Python script with a `main` function. This function can accept parameters (`request` and `store`) for interacting with payloads and storage:

```python
pythonCopy codedef main():  
    # Core logic here  

def main(request, store):  
    # Code utilizing payloads and persistent storage  
```

Here’s an example script for translating text:

```python
pythonCopy codefrom orbit_ai import TextTranslator  

def main(request, store):  
    """Translate text from one language to another."""  

    text = request.payload["text"]  
    source = request.payload["source"]  
    target = request.payload["target"]  

    translator = TextTranslator(model="orbit-mini")  
    result = translator.translate(text, source, target)  

    return {"translation": result}  
```

***

#### **Adding Dependencies**

List your Python packages in the **Requirements** section. Each package should be written on a new line, like this:

```makefile
makefileCopy codeorbit-ai==1.2.0  
requests==2.28.1  
```

***

#### **Setting Environment Variables**

Environment variables allow you to include external keys or configurations. Add them in `KEY=VALUE` format:

```makefile
makefileCopy codeAPI_KEY=your_api_key_here  
ENDPOINT=https://api.yourservice.com  
```

***

### **Step 2: Execute Your Agent**

Once your agent is created, you can execute it either:

1. **Manually**: Use the dashboard to trigger execution on demand.
2. **Scheduled**: Use cron expressions to set up recurring execution.

**Example: Executing an agent via Python SDK**

```python
pythonCopy codeimport agentorbit  

agentorbit.api_key = "YOUR_API_KEY"  

agent = agentorbit.Agent.retrieve(id="AGENT_ID")  
execution = agent.execute()  
```

***

#### **Working with Payloads**

You can pass JSON-serializable payloads when executing agents:

**Passing Payload via SDK**

```python
pythonCopy codeexecution = agent.execute(payload={"name": "Agent", "action": "start"})  
```

**Accessing Payload in the Script**

```python
pythonCopy codedef main(request, store):  
    print(request.payload)  # Outputs {"name": "Agent", "action": "start"}  
```

***

#### **Logging and Debugging**

Use `print()` or Python's logging module to debug your scripts. Logs are accessible via the dashboard or APIs:

```python
pythonCopy codeimport logging  

logger = logging.getLogger("agent-logger")  
logger.info("Agent started execution!")  
```

***

#### **Retrieving Results**

Agents return JSON-serializable outputs, which you can view in the dashboard or fetch via the SDK:

```python
pythonCopy codeprint(execution.return_value)  
```

***

With Agent Orbit, running Python agents in the cloud has never been easier. Start building your first agent today!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://agent-orbit.gitbook.io/agent-orbit-docs/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
