{
  "openapi": "3.1.0",
  "info": {
    "title": "My Zuplo API",
    "version": "1.0.0"
  },
  "paths": {
    "/v1/developer/api-key": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "post": {
        "summary": "Create API Key",
        "description": "",
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/api-keys)",
            "options": {}
          },
          "policies": {
            "inbound": [
              "open-id-jwt-auth-inbound"
            ]
          }
        },
        "operationId": "api-key-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/billing": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "post": {
        "summary": "Get billing information for request IDs",
        "description": "Returns cost information for the provided request IDs",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingResponse"
                }
              }
            }
          }
        },
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "billingHandler",
            "module": "$import(./modules/billing-handler)"
          },
          "policies": {
            "inbound": [
              "api-key-inbound"
            ]
          }
        },
        "operationId": "billing-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/upgrade-plan": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "post": {
        "summary": "Upgrade a given users plan",
        "description": "",
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/upgrade-plan-handler)",
            "options": {}
          },
          "policies": {
            "inbound": []
          }
        },
        "operationId": "upgrade-plan-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/wallet": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "get": {
        "summary": "Get wallet information",
        "description": "Returns wallet balance, payment method status, and transaction history for the authenticated user",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletResponse"
                }
              }
            }
          }
        },
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/wallet-balance-handler)"
          },
          "policies": {
            "inbound": [
              "open-id-jwt-auth-inbound"
            ]
          }
        },
        "operationId": "wallet-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/wallet/topup": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "post": {
        "summary": "Top up wallet balance",
        "description": "Creates a wallet transaction to add credits. Returns settled if card on file, pending otherwise.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TopUpRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletTransactionResponse"
                }
              }
            }
          }
        },
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/wallet-topup-handler)"
          },
          "policies": {
            "inbound": [
              "open-id-jwt-auth-inbound"
            ]
          }
        },
        "operationId": "wallet-topup-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/wallet/setup-payment": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "post": {
        "summary": "Setup payment method",
        "description": "Generates a Stripe checkout URL to setup payment method",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupPaymentResponse"
                }
              }
            }
          }
        },
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/customer-checkout-url-handler)"
          },
          "policies": {
            "inbound": [
              "open-id-jwt-auth-inbound"
            ]
          }
        },
        "operationId": "setup-payment-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/wallet/payment-method/{paymentMethodId}": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "delete": {
        "summary": "Delete payment method",
        "description": "Detaches a payment method from the customer's account",
        "parameters": [
          {
            "name": "paymentMethodId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The ID of the payment method to delete"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletePaymentMethodResponse"
                }
              }
            }
          }
        },
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/delete-payment-method-handler)"
          },
          "policies": {
            "inbound": [
              "open-id-jwt-auth-inbound"
            ]
          }
        },
        "operationId": "delete-payment-method-endpoint",
        "x-internal": true
      }
    },
    "/v1/developer/pricing": {
      "x-zuplo-path": {
        "pathMode": "open-api"
      },
      "get": {
        "summary": "Get model pricing information",
        "description": "Returns pricing information for all available models",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PricingResponse"
                }
              }
            }
          }
        },
        "x-zuplo-route": {
          "corsPolicy": "anything-goes",
          "handler": {
            "export": "default",
            "module": "$import(./modules/pricing-handler)"
          },
          "policies": {
            "inbound": []
          }
        },
        "operationId": "pricing-endpoint",
        "x-internal": true
      }
    }
  },
  "components": {
    "schemas": {
      "BillingRequest": {
        "type": "object",
        "properties": {
          "requestIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of request IDs to get billing information for"
          }
        },
        "required": [
          "requestIds"
        ]
      },
      "BillingRequestItem": {
        "type": "object",
        "properties": {
          "requestId": {
            "type": "string",
            "description": "The request ID"
          },
          "costNanoUsd": {
            "type": "integer",
            "minimum": 0,
            "description": "Cost in nano-USD (10^-9 USD)"
          }
        },
        "required": [
          "requestId",
          "costNanoUsd"
        ]
      },
      "BillingResponse": {
        "type": "object",
        "properties": {
          "requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingRequestItem"
            },
            "description": "Array of billing information for each request"
          }
        },
        "required": [
          "requests"
        ]
      },
      "WalletResponse": {
        "type": "object",
        "properties": {
          "wallets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Wallet"
            },
            "description": "Array of wallets for the user"
          },
          "hasPaymentMethod": {
            "type": "boolean",
            "description": "Whether the customer has a payment method on file"
          },
          "payment_methods": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Payment method ID"
                },
                "type": {
                  "type": "string",
                  "description": "Payment method type (e.g., 'card')"
                },
                "card": {
                  "type": "object",
                  "properties": {
                    "brand": {
                      "type": "string",
                      "description": "Card brand (e.g., 'visa', 'mastercard')"
                    },
                    "last4": {
                      "type": "string",
                      "description": "Last 4 digits of card number"
                    },
                    "exp_month": {
                      "type": "integer",
                      "description": "Expiration month"
                    },
                    "exp_year": {
                      "type": "integer",
                      "description": "Expiration year"
                    }
                  }
                }
              }
            },
            "description": "Customer's saved payment methods"
          },
          "wallet_transactions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lago_id": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "transaction_type": {
                  "type": "string"
                },
                "amount": {
                  "type": "string"
                },
                "credit_amount": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            },
            "description": "Recent wallet transactions"
          }
        }
      },
      "Wallet": {
        "type": "object",
        "properties": {
          "lago_id": {
            "type": "string",
            "description": "The Lago wallet ID"
          },
          "external_customer_id": {
            "type": "string",
            "description": "The external customer ID"
          },
          "name": {
            "type": "string",
            "description": "The wallet name"
          },
          "credits_ongoing_balance": {
            "type": "string",
            "description": "The current credits balance"
          },
          "currency": {
            "type": "string",
            "description": "The currency code"
          }
        }
      },
      "TopUpRequest": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "minimum": 0.01,
            "description": "Amount to top up in USD"
          }
        },
        "required": ["amount"]
      },
      "WalletTransactionResponse": {
        "type": "object",
        "properties": {
          "wallet_transaction": {
            "type": "object",
            "properties": {
              "lago_id": {
                "type": "string",
                "description": "Transaction ID"
              },
              "wallet_id": {
                "type": "string",
                "description": "Wallet ID"
              },
              "status": {
                "type": "string",
                "enum": ["pending", "settled"],
                "description": "Transaction status"
              },
              "transaction_type": {
                "type": "string",
                "description": "Type of transaction"
              },
              "amount": {
                "type": "string",
                "description": "Transaction amount"
              },
              "credit_amount": {
                "type": "string",
                "description": "Credits added"
              },
              "created_at": {
                "type": "string",
                "format": "date-time",
                "description": "Creation timestamp"
              }
            }
          }
        }
      },
      "SetupPaymentResponse": {
        "type": "object",
        "properties": {
          "lago_customer_id": {
            "type": "string"
          },
          "external_customer_id": {
            "type": "string"
          },
          "payment_provider": {
            "type": "string"
          },
          "checkout_url": {
            "type": "string",
            "description": "Stripe payment setup URL"
          }
        }
      },
      "DeletePaymentMethodResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the payment method was successfully deleted"
          },
          "payment_method": {
            "type": "object",
            "description": "The detached payment method"
          }
        }
      },
      "PricingResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "model_name": {
                  "type": "string",
                  "description": "Name of the model"
                },
                "model_info": {
                  "type": "object",
                  "properties": {
                    "input_cost_per_token": {
                      "oneOf": [
                        {"type": "number"},
                        {"type": "string"}
                      ],
                      "description": "Cost per input token"
                    },
                    "output_cost_per_token": {
                      "oneOf": [
                        {"type": "number"},
                        {"type": "string"}
                      ],
                      "description": "Cost per output token"
                    }
                  }
                }
              }
            },
            "description": "Array of model pricing information"
          }
        }
      }
    }
  }
}