Skip to content

Client

Bases: AgenticResumeMixin, ConversationsMixin, ProfilesMixin, GroupsMixin, CompaniesMixin, InterviewsMixin, LibraryMixin, ContentMixin, SocialMixin, HttpMixin

SuperMe API client with OpenAI-compatible interface.

Communicates with the SuperMe MCP server via JSON-RPC.

Example::

client = SuperMeClient(api_key="your-superme-api-key")

# OpenAI-style
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "What is PMF?"}],
    username="ludo",
)
print(response.choices[0].message.content)

# Convenience helpers
answer = client.ask("What is PMF?", username="ludo")

# Low-level MCP access
tools = client.low_level.list_tools()
Source code in superme_sdk/client.py
class SuperMeClient(
    AgenticResumeMixin,
    ConversationsMixin,
    ProfilesMixin,
    GroupsMixin,
    CompaniesMixin,
    InterviewsMixin,
    LibraryMixin,
    ContentMixin,
    SocialMixin,
    HttpMixin,
):
    """SuperMe API client with OpenAI-compatible interface.

    Communicates with the SuperMe MCP server via JSON-RPC.

    Example::

        client = SuperMeClient(api_key="your-superme-api-key")

        # OpenAI-style
        response = client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": "What is PMF?"}],
            username="ludo",
        )
        print(response.choices[0].message.content)

        # Convenience helpers
        answer = client.ask("What is PMF?", username="ludo")

        # Low-level MCP access
        tools = client.low_level.list_tools()
    """

    def __init__(
        self,
        api_key: str,
        base_url: str = "https://mcp.superme.ai",
        rest_base_url: str = "https://www.superme.ai",
        timeout: float = 120.0,
    ):
        if not api_key:
            raise ValueError("api_key is required")
        self.api_key = api_key
        self.base_url = base_url.rstrip("/")
        self.rest_base_url = rest_base_url.rstrip("/")
        _auth_headers = {
            "Authorization": f"Bearer {self.api_key}",
            "Content-Type": "application/json",
            "Accept": "application/json, text/event-stream",
        }
        self._http = httpx.Client(
            base_url=self.base_url,
            headers=_auth_headers,
            timeout=timeout,
            follow_redirects=True,
        )
        self._rest_http = httpx.Client(
            base_url=self.rest_base_url,
            headers={
                "Authorization": f"Bearer {self.api_key}",
                "Content-Type": "application/json",
                "Accept": "application/json, text/event-stream",
            },
            timeout=timeout,
        )
        self._rpc_id = 0
        self.chat = Chat(self)
        self.low_level = LowLevel(self)

    # ------------------------------------------------------------------
    # Properties
    # ------------------------------------------------------------------

    @property
    def token(self) -> str:
        """Current API token."""
        return self.api_key

    @property
    def user_id(self) -> Optional[str]:
        """Extract user_id from the JWT token payload."""
        return _decode_jwt(self.api_key).get("user_id")

    # ------------------------------------------------------------------
    # Context manager / cleanup
    # ------------------------------------------------------------------

    def close(self) -> None:
        """Close the underlying HTTP client."""
        self._rest_http.close()
        self._http.close()

    def __enter__(self) -> "SuperMeClient":
        return self

    def __exit__(self, *args: Any) -> None:
        self.close()

token property

token: str

Current API token.

user_id property

user_id: Optional[str]

Extract user_id from the JWT token payload.

close

close() -> None

Close the underlying HTTP client.

Source code in superme_sdk/client.py
def close(self) -> None:
    """Close the underlying HTTP client."""
    self._rest_http.close()
    self._http.close()