feat(clients): xai core: Responses, chat, tools, media, batch, models, ChatModel
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
// Models API: /v1/models (generic, OpenAI-compatible), /v1/language-models,
|
||||
// /v1/image-generation-models, /v1/video-generation-models,
|
||||
// /v1/embedding-models. One ModelInfo covers all five shapes; fields a shape
|
||||
// does not carry stay at their defaults. Prices are as xAI reports them
|
||||
// (USD cents per 100 million tokens unless stated; embedding prices per
|
||||
// million tokens; image pricing tiers in 1/100,000,000 USD cent).
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xai/core/service.h"
|
||||
|
||||
namespace molo::xai::core {
|
||||
|
||||
enum class ModelKind { kGeneric, kLanguage, kImage, kVideo, kEmbedding };
|
||||
|
||||
struct ImagePriceTier {
|
||||
std::string quality, resolution;
|
||||
long price_per_image = 0;
|
||||
};
|
||||
|
||||
struct ModelInfo {
|
||||
ModelKind kind = ModelKind::kGeneric;
|
||||
std::string id, object, owned_by, version, fingerprint;
|
||||
long created = 0;
|
||||
std::vector<std::string> aliases, input_modalities, output_modalities;
|
||||
std::optional<long> context_length; // generic /v1/models only
|
||||
std::optional<long> long_context_threshold;
|
||||
// Named prices: prompt_text_token_price, cached_prompt_text_token_price,
|
||||
// completion_text_token_price, *_long_context, prompt_image_token_price,
|
||||
// search_price, image_price.
|
||||
std::map<std::string, long> prices;
|
||||
std::vector<ImagePriceTier> image_pricing;
|
||||
std::optional<long> max_prompt_length; // image models
|
||||
std::vector<std::string> reasoning_efforts; // capabilities.reasoning_effort
|
||||
std::string default_reasoning_effort;
|
||||
Json raw;
|
||||
|
||||
static ModelInfo parse(ModelKind kind, const Json& doc);
|
||||
bool accepts_effort(const std::string& effort) const;
|
||||
};
|
||||
|
||||
struct ModelList {
|
||||
std::vector<ModelInfo> models;
|
||||
bool truncated = false; // more entries than Caps::kMaxAccumulatedItems
|
||||
};
|
||||
|
||||
class ModelsService : public XaiService {
|
||||
public:
|
||||
explicit ModelsService(std::shared_ptr<llm::ApiClient> client) : XaiService(std::move(client)) {}
|
||||
ModelList list(ModelKind kind = ModelKind::kGeneric);
|
||||
ModelInfo get(ModelKind kind, const std::string& model_id);
|
||||
};
|
||||
|
||||
} // namespace molo::xai::core
|
||||
Reference in New Issue
Block a user