UG AI Engine for children
Python SDK
Python SDK
Support
Support
ย
๐งฉ UG Labs API Documentation
๐ Live API (Staging)
Interact with the API here โ
ย
Sign into the platform here
Interact
To see a list of interact messages - follow this
๐ Authentication Overview
UG Labs uses a role- and permission-based authentication system with two types of API keys:
- Developer API Key โ used by developers to manage accounts and players.
- Service Account API Key โ used by players to authenticate from your client app.
All HTTP requests auth after obtaining a token is done by adding the header:
Authorization: Bearer <token>๐จโ๐ป Developer Authentication
Developers should log in using Google SSO to access their UG Labs account and retrieve their Developer API Key.
This key allows you to:
- Create, edit, and delete players within your organization.
- Generate Service Account API Keys that players will use to authenticate.
1๏ธโฃ Get a Developer Access Token
Get a developer API Key by logging into here and then navigating to your Profile page
Then using that API key - you can exchange for an access token
Request
POST /api/auth/login Content-Type: application/json { "api_key": "{{DEVELOPER_API_KEY}}" }
Response
{ "access_token": "{YOUR_ACCESS_TOKEN}" }
โก๏ธ Save this
access_token and include it in the Authorization header for all developer-level requests.๐งโ๐ฎ Player Management
Once you have a valid Developer Access Token, you can create new players in your account.
External id could be anything - this endpoint is usually called from within your server (after you validated that this email belongs to the player for example). This could be anything such as phone number or any other identifier.
2๏ธโฃ Create a Player
Request
POST {{baseUrl}}/api/players Content-Type: application/json Authorization: Bearer {DEVELOPER_ACCESS_TOKEN} { "external_id": "someemail@gmail.com" }
Response
{ "pk": 1, "external_id": "someemail@gmail.com", "federated_id": "<FEDERATED_ID_UNIQUE_TO_PLAYER>" }
โ ๏ธ Note:Thefederated_idreturned here is required for the playerโs login process - usually this secret is stored on the playerโs device for future sign-in (See Player Authentication below)
๐งพ Service Account API Key
The Service Account API Key is used by players to authenticate.
This key should be stored securely on the client side and tied to a specific player.
You can create or retrieve your Service Account API Key from the UG Labs dashboard
๐ฎ Player Authentication
Players log in using the Service Account API Key and their federated_id.
Those 2 objects can be stored on the user device.
3๏ธโฃ Get a Player Access Token
If you are just testing the system - you can quickly create a demo test player by using this link
This should give you some
federated_id you can use to test out the systemRequest
POST {{baseUrl}}/api/auth/login Content-Type: application/json { "api_key": "SERVICE_ACCOUNT_API_KEY", "federated_id": "PLAYERS_FEDERATED_ID" }
Response
{ "access_token": "{YOUR_ACCESS_TOKEN}" }
โก๏ธ Use this
access_token for the entire duration of the playerโs session.This access token allows you to mainly use the
interact endpointโ Summary โ Full Authentication Flow - Testing purposes
Here is a full flow to test out the system
- [One time only] Login via Google SSO here
- Create a
Service Account API KeyCreate one here.
- Create a new test player โ Get
federated_idhere
- Player Login โ Use
Service Account API Key+federated_idโ Get Player Access Token.
โ Summary โ Full Authentication Flow
When you are ready to go live - here is how the full flow would look like
- [One time only] Login via Google SSO โ Access your Developer API Key.
- Create a Service Account API Key [With playerCreate permission]
- Create a Service Account API Key โ Store securely on the client side. Create one here.
- Your Server โ Login with that service account โ Get Service Account Access Token
- Player Client โ Your server โ Use Service Account Access Token โ Create a new Player (retrieve
federated_id).
- Player Login โ Use
SERVICE_ACCOUNT_API_KEY+federated_idโ Get Player Access Token.
ย
๐น๏ธ Interaction Flow
The interaction endpoint is a websocket that is accessed by players.
After making a call to get an access token (See above) - the player then uses that as the first message to the websocket.
ย
URL:
wss://pug.stg.uglabs.app/interactย
List of messages can be found here:
Message Flow:
1๏ธโฃ Authorization
{ "type":"request", "kind":"authenticate", "access_token":"SECRET.ACCESS_TOKEN", "uid":"07eb55fb-b094-4407-b957-7f9782a3685a", "client_start_time":"2025-10-04T20:27:07.601Z" }
ย
Response:
{ "type":"response", "uid":"07eb55fb-b094-4407-b957-7f9782a3685a", "kind":"authenticate", "client_start_time":"2025-10-04T20:27:07.601000Z", "server_start_time":"2025-10-04T20:27:07.797467Z", "server_end_time":"2025-10-04T20:27:07.813188Z" }
ย
2๏ธโฃ Set Configuration
This is where you set your prompt, safety_policy, utilities (Either through strings or through references)
[See
config full message params here]{ "type":"request", "kind":"set_configuration", "config": { "prompt":"a game of Scattegories where the user needs to say a country that starts with the letter B" }, "uid":"db004255-b063-437d-81fa-6cb2f10e50a8", "client_start_time":"2025-10-04T20:27:07.799Z" }
Response:
{ "type":"response", "uid":"db004255-b063-437d-81fa-6cb2f10e50a8", "kind":"set_configuration", "client_start_time":"2025-10-04T20:27:07.799000Z", "server_start_time":"2025-10-04T20:27:07.979354Z", "server_end_time":"2025-10-04T20:27:07.979614Z" }
3๏ธโฃ Stream
Sending a message with a โ.โ is simply a way to tell the ai to send a response back to the user given all the audio that was sent (None in this request) based on the prompt that was given
(See full message params here)
{ "type":"stream", "kind":"interact", "text":".", "context":{}, "audio_output":true, "uid":"2abcafa6-f32a-43b2-9fca-17b98dc292c4", "client_start_time":"2025-10-04T20:27:07.964Z" }
{ "type":"stream", "uid":"2abcafa6-f32a-43b2-9fca-17b98dc292c4", "kind":"interact", "client_start_time":"2025-10-04T20:27:07.964000Z", "server_start_time":"2025-10-04T20:27:08.143381Z", "server_end_time":"2025-10-04T20:27:08.970967Z", "event":"text", "text":"Okay" }
[โฆ] At that point - you should be getting many stream messages of audio and text that will end with this message
{ "type":"stream", "uid":"2abcafa6-f32a-43b2-9fca-17b98dc292c4", "kind":"close" }
ย
General endpoints
Me [Developer only token]
GET /api/users/meRequires authentication
At any point you can call this endpoint with a valid Developer access token and receive a response.
Response:
{ "pk": 1, "name": "Johnny Depp", "email": "johnny.depp@somecompany.com", "api_key": "MY_API_KEY", "teams": [ { "pk": 2, "name": "somecompany.com" } ] }
Players [Developer only token]
List Players
GET /api/players/Requires authentication
Returns the list of all the available players in the current userโs team.
{ "players": [ { "pk": 1, "federated_id": "14abcabcabcabc3bbddf19b357ca0dc2" }, { "pk": 3, "federated_id": "1111ccccdddd037553cc1628f80c6c55" } ] }
ย
Get Player
GET /api/players/{player_pk}Requires authentication
ย
Returns the full details of a given player in the current userโs team.
Response:
{ "pk": 3, "external_id": "secret2", "federated_id": "1111ccccdddd037553cc1628f80c6c55" }
ย
Delete Player
DELETE /api/players/{player_pk}Requires authentication
ย
Deletes a given player in the current userโs team.
ย
For the full list of api endpoints - follow this
๐งฉ UG Labs API Documentation๐ Live API (Staging)Interact๐ Authentication Overview๐จโ๐ป Developer Authentication1๏ธโฃ Get a Developer Access Token๐งโ๐ฎ Player Management2๏ธโฃ Create a Player๐งพ Service Account API Key๐ฎ Player Authentication3๏ธโฃ Get a Player Access Tokenโ
Summary โ Full Authentication Flow - Testing purposesโ
Summary โ Full Authentication Flow๐น๏ธ Interaction FlowMessage Flow:1๏ธโฃ Authorization2๏ธโฃ Set Configuration3๏ธโฃ StreamGeneral endpointsMe [Developer only token]Players [Developer only token]