Skip to content

feat(developer-api): Add projects, billing providers and API key creation workflow #111

@eliteprox

Description

@eliteprox

Problem

As an Naap user,

I can use the Developer API Manager plugin to create projects to organize my Developer API Keys. Each user will begin with a Default Project which will be used when no project is selected. Each API Key must belong to a project and a billing provider.

Each Developer API Key will be valid for a single billing provider (i.e. DayDream) so that my livepeer-python-gateway can authenticate with a billing provider when streaming to the Livepeer network

Proposed Solution

Database changes

Add alongside the existing DevApi models:

model DevApiProject {
  id        String   @id @default(uuid())
  userId    String
  name      String
  isDefault Boolean  @default(false)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  apiKeys DevApiKey[]

  @@unique([userId, name])
  @@index([userId])
  @@schema("plugin_developer_api")
}
  1. Modify DevApiKey table
model DevApiKey {
  id                   String              @id @default(uuid())
  userId               String
  projectId            String
  project              DevApiProject       @relation(fields: [projectId], references: [id], onDelete: Cascade)
  billingProviderKeyId String
  billingProviderKey   BillingProviderKey  @relation(fields: [billingProviderKeyId], references: [id], onDelete: Restrict)
  modelId              String
  model                DevApiAIModel       @relation(fields: [modelId], references: [id], onDelete: Cascade)
  gatewayOfferId       String?
  gatewayOffer         DevApiGatewayOffer? @relation(fields: [gatewayOfferId], references: [id], onDelete: SetNull)
  keyHash              String              @unique
  keyPrefix            String
  status               DevApiKeyStatus     @default(ACTIVE)
  createdAt            DateTime            @default(now())
  lastUsedAt           DateTime?
  revokedAt            DateTime?

  usageLogs DevApiUsageLog[]

  @@index([userId])
  @@index([projectId])
  @@index([billingProviderKeyId])
  @@index([modelId])
  @@index([status])
  @@index([keyHash])
  @@schema("plugin_developer_api")
}

Note: billingProviderKeyId uses onDelete: Restrict -- you cannot delete a billing provider key if API keys are still linked to it.

UI Changes

Link Billing Provider
Image

Create a new API Key
Image

Retrieve API Key
Image

Note The format of the API Key needs to still be determined. OpenID connect and JWT identifiers for the NaaP user might be more helpful (simply enriching the billing provider's token with assertion of the NaaP user identity)

List API Keys by Project and Revoke
Image

Alternatives Considered

Scope

  • Shell / core platform
  • Plugin SDK
  • Existing plugin: developer-api
  • New plugin
  • Infrastructure / CI
  • Documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions