Stability, BFL, Runway, Luma, Replicate, fal, Ideogram, Recraft, Leonardo, MiniMax, Kling, Higgsfield: call tables checked against vendor specs/SDKs, ImageGenerator/VideoGenerator seam with capped polling, /ai/media demo. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
73 lines
2.7 KiB
C++
73 lines
2.7 KiB
C++
#pragma once
|
|
|
|
// MediaRegistry: the one list of providers in package media, what each one
|
|
// can do, which environment variables it needs and how well its API surface
|
|
// is verified. Builds generators and call services from the environment on
|
|
// demand and caches them. Products without a public API are listed too, with
|
|
// the reason, so nothing is silently missing.
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "vendors/media/common/job.h"
|
|
#include "vendors/media/common/media_service.h"
|
|
|
|
namespace molo::media {
|
|
|
|
// How the provider's call table was checked (see each SPEC).
|
|
enum class Evidence {
|
|
kOpenApi, // vendor-published OpenAPI document, checked by tools/check_spec.py
|
|
kSdk, // official SDK source, checked by tools/check_spec.py
|
|
kDocs, // vendor doc pages, checked by tools/check_spec.py
|
|
kProbeOnly // no machine-readable source: community sources plus live probes
|
|
};
|
|
|
|
struct ProviderInfo {
|
|
std::string id;
|
|
std::string name;
|
|
std::vector<std::string> env; // every variable the credential needs
|
|
bool image = false;
|
|
bool video = false;
|
|
Evidence evidence = Evidence::kOpenApi;
|
|
std::string console_url; // where the key is created
|
|
std::string account_key; // table key of a free read that proves the credential ("" = none)
|
|
std::string note;
|
|
};
|
|
|
|
struct UnsupportedProduct {
|
|
std::string name;
|
|
std::string reason;
|
|
};
|
|
|
|
class MediaRegistry {
|
|
public:
|
|
static const std::vector<ProviderInfo>& providers();
|
|
static const std::vector<UnsupportedProduct>& unsupported();
|
|
static const ProviderInfo* find(const std::string& id);
|
|
static const char* evidence_name(Evidence evidence);
|
|
// Table of one provider (no credential needed). Throws ApiError::invalid.
|
|
static const CallTable& table(const std::string& id);
|
|
|
|
// True when every env variable the provider needs is set (llm::Config).
|
|
static bool configured(const std::string& id);
|
|
|
|
// Built from the environment on first use, then cached for this registry.
|
|
// `key` picks the host for providers with two (fal: queue.* / platform.*).
|
|
std::shared_ptr<MediaService> service(const std::string& id, const std::string& key = "");
|
|
std::shared_ptr<ImageGenerator> image(const std::string& id);
|
|
std::shared_ptr<VideoGenerator> video(const std::string& id);
|
|
|
|
// Free read that proves the credential works (balance, account, models).
|
|
// Returns the provider's JSON. Throws NotConfiguredError without a key.
|
|
Json account(const std::string& id);
|
|
|
|
private:
|
|
std::map<std::string, std::shared_ptr<MediaService>> services_;
|
|
std::map<std::string, std::shared_ptr<ImageGenerator>> images_;
|
|
std::map<std::string, std::shared_ptr<VideoGenerator>> videos_;
|
|
};
|
|
|
|
} // namespace molo::media
|