Skip to content

A project holds everything your agent uses: its channels, messages, and API keys. In this guide, you create a key for your project, install the client for your language, and use them to make your first request.

Prerequisites

You need:

  • A Photon Beta account. Sign up in the dashboard if you don't have one.
  • One of these: Node.js 24 or later, Python 3.11 or later, Rust 1.88 or later, or Go 1.25 or later.
1

Choose a project

Open the Beta dashboard. Select a project in the switcher at the top of the sidebar, or create one.

2

Create an API key

Open API keys. Copy the project ID under the page title. It starts with pho_prj_.

Under Create an API key, enter a name, choose how long the key lasts, and select Create key. Choose Custom, then select the permissions your code needs:

PermissionLets your code
project:readRead the project and receive messages.
project:writeSend messages.
platforms:readRead channel settings, such as a Voice profile. Optional.
platforms:writeConnect channels from code instead of the dashboard. Optional.
Select project:read and project:write to follow the messaging guides. Sample data; no key is shown.

Select Create key and copy the key. It is shown only once. If you lose it, create a new key and revoke the old one.

Full access in the Create key menu also works. It gives the key every permission in the project, which is more than these guides need.

3

Set environment variables

In the terminal where you will run your code, set the project ID and the key you copied:

Code
export PHOTON_PROJECT_ID="pho_prj_REPLACE_WITH_YOUR_PROJECT_ID"
export PHOTON_API_KEY="pho_sk_REPLACE_WITH_YOUR_PROJECT_API_KEY"
4

Install the client

Create a directory for your agent and install the client for one language. These guides use version 0.6.0.

mkdir photon-first-agent && cd photon-first-agent
npm init -y && npm pkg set type=module
npm install @photon-ai/api@0.6.0
5

Make your first request

Read your project with your new key. Save this as first-request.ts, first_request.py, src/main.rs, or first_request.go:

import { Photon } from "@photon-ai/api";

const { PHOTON_API_KEY, PHOTON_PROJECT_ID } = process.env;
if (!PHOTON_API_KEY || !PHOTON_PROJECT_ID) throw new Error("Set PHOTON_API_KEY and PHOTON_PROJECT_ID");

const photon = new Photon({
  headers: { Authorization: `Bearer ${PHOTON_API_KEY}` },
});

const project = await photon.projects.get({ path: { projectId: PHOTON_PROJECT_ID } });
console.log(`Connected to ${project.name} (${project.projectId})`);

Run it:

node first-request.ts

You should see your project's name and ID:

Code
Connected to My project (pho_prj_...)

Troubleshooting

ErrorWhat to check
401The key is wrong, expired, or revoked, or PHOTON_API_KEY isn't set in this terminal.
403The key belongs to another project, or it lacks project:read.
404PHOTON_PROJECT_ID doesn't match the ID on the API keys page.

Next: connect a channel

Give your agent a way to receive messages. Pick a channel:

iMessage

Text a shared line from your own phone.

Email

Receive email on your own domain.

SMS

Text a Photon number from your phone.

WhatsApp Business

Connect a Photon SMS number to WhatsApp.

Telegram

Create a bot for your agent.

Voice

Route phone calls to a voice agent.