Using slim.to with OpenAI (ChatGPT & Agents SDK)
Two ways in: the MCP server (Agents SDK / ChatGPT connectors) or the REST API (custom GPT Actions, scripts).
Prerequisite for both: a personal API key.
Approach 1 — MCP server
OpenAI Agents SDK (Python)
The Agents SDK runs local stdio MCP servers directly, so your agent can upload files it just wrote:
from agents import Agent, Runner
from agents.mcp import MCPServerStdio
async def main():
async with MCPServerStdio(
params={
"command": "uvx",
"args": ["--from", "/path/to/slimto/mcp", "slimto-mcp"],
"env": {"SLIMTO_API_KEY": "slim_your_key_here"},
}
) as slimto:
agent = Agent(
name="Analyst",
instructions=(
"When you produce a report or file the user will share, "
"upload it with create_link_from_file and give them the short URL."
),
mcp_servers=[slimto],
)
result = await Runner.run(agent, "Write the Q3 summary PDF and share it.")
print(result.final_output)
ChatGPT (web) — hosted connector
slim.to ships a hosted remote MCP server with OAuth:
- In ChatGPT: Settings → Connectors (enable Developer mode if you don't see the option) → Create / Add connector.
- Enter the MCP server URL
https://slim.to/mcpwith OAuth authentication. - ChatGPT opens the slim.to sign-in/consent page — click Authorize.
ChatGPT can then shorten URLs, publish HTML/text content it generates as
tracked links (create_link_from_content), list your links, and read your
analytics. Revoke access anytime from Dashboard → Settings → Connected apps.
The same URL works with the Responses API mcp tool for API-side agents:
tools=[{"type": "mcp", "server_url": "https://slim.to/mcp",
"authorization": "<oauth-access-token-or-slim_personal-key>"}]
Approach 2 — REST API
Custom GPT Action (works in ChatGPT today)
- In ChatGPT: Explore GPTs → Create a GPT → Configure → Create new action.
- Import the schema from
https://slim.to/openapi/openapi.json, or paste a minimal spec coveringPOST /api/v1/links,GET /api/v1/links, andGET /api/v1/analytics/links/{link_id}. - Under Authentication choose API Key, header name
X-API-Key, and paste yourslim_…key. - In the GPT's instructions, add:
When the user asks to shorten or share a URL, call createLink and reply with the short_url. When they ask who opened a link, call getLinkAnalytics.
Note: GPT Actions can send JSON, so URL shortening and analytics work great; ChatGPT cannot attach a locally generated binary file to an Action call, so file uploads still need the API from a machine (below) or the web app.
Scripts / anything with HTTP
import requests, os
def slimto_upload(path: str, title: str | None = None) -> str:
with open(path, "rb") as fh:
r = requests.post(
"https://slim.to/api/v1/files",
headers={"X-API-Key": os.environ["SLIMTO_API_KEY"]},
files={"file": fh},
data={"title": title or ""},
)
r.raise_for_status()
return r.json()["link"]["short_url"]
Wire that up as a normal function tool in any OpenAI tool-calling loop; the full endpoint reference is in the API quickstart.
Which approach?
| Hosted MCP connector | MCP (Agents SDK, local) | GPT Action | Raw REST | |
|---|---|---|---|---|
| Works inside chatgpt.com | ✅ | ❌ | ✅ | ❌ |
| Upload generated content | ✅ | ✅ (+ local files) | ❌ | ✅ |
| Setup | paste URL + Authorize | config block | one-time GPT setup | a few lines of code |