Miosa (Miosa v1.0.1)

Copy Markdown View Source

Official Elixir SDK for the MIOSA API.

MIOSA provides cloud computers (Linux VMs with a full desktop) accessible via API. This SDK covers computer management, desktop control, file operations, and command execution. The desktop and exec primitives let your own AI agent (Claude, GPT, your own model, etc.) drive a MIOSA computer.

Installation

Add to your mix.exs:

defp deps do
  [
    {:miosa, "~> 0.1.0"}
  ]
end

Quick Start

# Build a client
client = Miosa.client("msk_u_your_api_key")

# Create and start a computer
{:ok, computer} = Miosa.Computers.create(client, %{name: "my-workspace"})
:ok = Miosa.Computer.start(client, computer.id)
{:ok, computer} = Miosa.Computer.wait_until_running(client, computer.id)

# Control the desktop
{:ok, png} = Miosa.Desktop.screenshot(client, computer.id)
:ok = Miosa.Desktop.click(client, computer.id, 500, 300)
:ok = Miosa.Desktop.type(client, computer.id, "Hello, world!")
:ok = Miosa.Desktop.key(client, computer.id, "Return")

# Run commands
{:ok, result} = Miosa.Exec.bash(client, computer.id, "echo hello")
IO.puts(result.output)

# Upload and download files
:ok = Miosa.Files.upload(client, computer.id, "./local.txt", "/home/user/file.txt")
{:ok, content} = Miosa.Files.download(client, computer.id, "/home/user/file.txt")

# Drive the desktop yourself with your own AI agent — the SDK gives
# you the primitives (screenshot/click/type/key), you provide the loop:
{:ok, png} = Miosa.Desktop.screenshot(client, computer.id)
# ... pass `png` to your LLM, get back actions, replay via Miosa.Desktop ...

# Clean up
:ok = Miosa.Computer.stop(client, computer.id)
:ok = Miosa.Computer.destroy(client, computer.id)

API Key

Get your API key from the MIOSA dashboard at https://app.miosa.ai/settings/api. Keys have the format msk_u_... (user), msk_a_... (admin), or msk_p_... (platform).

Set via environment variable for safety:

client = Miosa.client(System.fetch_env!("MIOSA_API_KEY"))

Modules

Summary

Functions

Creates a new MIOSA API client.

Functions

client(api_key, opts \\ [])

@spec client(
  String.t(),
  keyword()
) :: Miosa.Client.t()

Creates a new MIOSA API client.

This is the entry point for all SDK operations. The returned client is a plain struct — it is stateless and safe to share across processes.

Arguments

  • api_key — Your MIOSA API key. Must start with "msk_".

Options

  • :base_url — Override the API base URL. Defaults to https://api.miosa.ai/api/v1. Useful for local development with a self-hosted MIOSA instance.
  • :timeout — Connection timeout in milliseconds. Defaults to 30_000.
  • :receive_timeout — Receive timeout for long-running requests. Defaults to 60_000.
  • :retry — Enable automatic retry on transient failures. Defaults to false.

Raises

Example

client = Miosa.client("msk_u_abcdef123")

# Custom base URL for local dev
client = Miosa.client("msk_u_abcdef123", base_url: "http://localhost:4000/api/v1")