getModel method

Future<AIModel?> getModel(
  1. String modelId
)

Get a specific model by ID

Implementation

Future<AIModel?> getModel(String modelId) async {
  try {
    final responseData = await client.get('models/$modelId');

    return AIModel(
      id: responseData['id'] as String,
      description: responseData['description'] as String?,
      object: responseData['object'] as String? ?? 'model',
      ownedBy: responseData['owned_by'] as String?,
    );
  } catch (e) {
    if (e is ResponseFormatError && e.message.contains('404')) {
      return null;
    }
    rethrow;
  }
}