docs/doc/developer/api/keys.mdx
response = requests.get(
"https://api.omi.me/v1/dev/keys",
headers={"Authorization": f"Bearer {API_KEY}"}
)
keys = response.json()
```
response = requests.post(
"https://api.omi.me/v1/dev/keys",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={"name": "My New Integration"}
)
new_key = response.json()
print(f"Store this key securely: {new_key['key']}")
```
response = requests.delete(
f"https://api.omi.me/v1/dev/keys/key_789ghi",
headers={"Authorization": f"Bearer {API_KEY}"}
)
if response.status_code == 204:
print("Key revoked successfully")
```
API_KEY = "omi_dev_your_api_key"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
def list_keys():
"""List all API keys"""
response = requests.get(
"https://api.omi.me/v1/dev/keys",
headers=headers
)
return response.json()
def create_key(name):
"""Create a new API key"""
response = requests.post(
"https://api.omi.me/v1/dev/keys",
headers=headers,
json={"name": name}
)
return response.json()
def revoke_key(key_id):
"""Revoke an API key"""
response = requests.delete(
f"https://api.omi.me/v1/dev/keys/{key_id}",
headers=headers
)
return response.status_code == 204
# List existing keys
print("Current API keys:")
for key in list_keys():
last_used = key.get("last_used_at", "Never")
print(f" - {key['name']} ({key['key_prefix']}...) - Last used: {last_used}")
# Create a new key
print("\nCreating new key...")
new_key = create_key("Test Integration")
print(f"Created: {new_key['name']}")
print(f"Key: {new_key['key']}") # Store this securely!
# Revoke a key (example)
# if revoke_key("key_123abc"):
# print("Key revoked successfully")
```
async function listKeys() {
const response = await fetch("https://api.omi.me/v1/dev/keys", { headers });
return response.json();
}
async function createKey(name) {
const response = await fetch("https://api.omi.me/v1/dev/keys", {
method: "POST",
headers,
body: JSON.stringify({ name })
});
return response.json();
}
async function revokeKey(keyId) {
const response = await fetch(`https://api.omi.me/v1/dev/keys/${keyId}`, {
method: "DELETE",
headers
});
return response.status === 204;
}
// List existing keys
console.log("Current API keys:");
const keys = await listKeys();
keys.forEach(key => {
const lastUsed = key.last_used_at || "Never";
console.log(` - ${key.name} (${key.key_prefix}...) - Last used: ${lastUsed}`);
});
// Create a new key
console.log("\nCreating new key...");
const newKey = await createKey("Test Integration");
console.log(`Created: ${newKey.name}`);
console.log(`Key: ${newKey.key}`); // Store this securely!
// Revoke a key (example)
// if (await revokeKey("key_123abc")) {
// console.log("Key revoked successfully");
// }
```
You can also manage API keys directly in the Omi app:
<Steps> <Step title="Open Omi App" icon="mobile"> Launch the Omi app on your device </Step> <Step title="Navigate to Settings" icon="gear"> Go to **Settings → Developer** </Step> <Step title="Manage Keys" icon="key"> Under "Developer API Keys" you can: - View all your keys - Create new keys - Delete existing keys </Step> </Steps> <Info> Keys created in the app and via the API are the same - you can manage them from either place. </Info>