Skip to main content
Glama
http_client.py1.39 kB
""" HTTP client factory and configuration. """ from typing import Any import httpx from ..domain.config import ApiConfig class HttpClientFactory: """Factory for creating HTTP clients with proper configuration.""" @staticmethod def create_api_client(config: ApiConfig) -> httpx.AsyncClient: """ Create an HTTP client configured for the Freepik API. Args: config: API configuration containing base URL, API key, and timeout. Returns: Configured HTTP client for Freepik API. """ return httpx.AsyncClient( base_url=config.base_url, headers={"x-freepik-api-key": config.api_key}, timeout=config.timeout, ) @staticmethod def create_dynamic_client() -> httpx.AsyncClient: """ Create an HTTP client with fresh configuration from environment. This method reads the current environment configuration each time it's called, allowing for dynamic API key updates without server restart. Returns: Configured HTTP client with current environment settings. """ config = ApiConfig.from_environment() return httpx.AsyncClient( base_url=config.base_url, headers={"x-freepik-api-key": config.api_key}, timeout=config.timeout, )

Implementation Reference

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/freepik-company/freepik-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server