Inference Logoinference.sh

X.com Integration

Connect X.com (formerly Twitter) to your agents.


Overview

The X.com integration lets your agents post tweets, read timelines, manage follows, and interact with the X API v2.

Why "Bring Your Own Key" (BYOK)?

X.com's API has strict rate limits and requires developer account approval. Instead of sharing our API quota across all users (which would quickly hit limits), you use your own X Developer app credentials.

Benefits:

  • Your own rate limits — not shared with other users
  • Full control — you decide what permissions to grant
  • Direct billing — API costs go to your X developer account

Prerequisites

Before connecting, you'll need:

  1. An X.com (Twitter) account
  2. A verified phone number on that account
  3. An X Developer account (free tier available)
  4. An X Developer app with OAuth 2.0 configured

Step 1: Create an X Developer Account

  1. Go to the X Developer Portal
  2. Click Sign up (or Sign in if you have an account)
  3. Complete the application:
    • Describe your use case (e.g., "Building AI agents to help manage social media")
    • Agree to the Developer Agreement
  4. Wait for approval (usually instant for free tier)

Step 2: Create a Project and App

  1. In the Developer Portal, go to Projects & Apps
  2. Click + Create Project
  3. Name your project (e.g., "Inference.sh Agents")
  4. Select your use case
  5. Click Create App
  6. Name your app (e.g., "My Agent Bot")
  7. Save your API Key and API Secret — you'll need these

Step 3: Configure OAuth 2.0

  1. In your app settings, go to User authentication settings
  2. Click Set up
  3. Configure these settings:

App permissions

Choose based on what you need:

PermissionAllows
ReadRead tweets and profile info
Read and writeRead + post tweets
Read, write, and Direct messageFull access including DMs

Type of App

Select Web App, Automated App or Bot (Confidential client)

App info

FieldValue
Callback URIhttps://app.inference.sh/settings/secrets/oauth/x
Website URLYour website or https://inference.sh
Terms of service(optional)
Privacy policy(optional)
  1. Click Save
  2. Copy your Client ID and Client Secret

Important: The callback URI must match exactly, including the /x at the end which identifies the provider.


Step 4: Connect in inference.sh

Configure credentials

  1. Go to Settings → Secrets → Integrations
  2. Find X.com and click Configure
  3. Enter your OAuth 2.0 credentials from Step 3:
    • Client ID
    • Client Secret
  4. Click Save credentials

These are stored securely as encrypted secrets (X_CLIENT_ID and X_CLIENT_SECRET).

Authorize the connection

  1. Click Connect (now available after configuring)
  2. You'll be redirected to X.com to authorize
  3. Review the permissions and click Authorize app
  4. Done! Your X.com integration is now active.

Capabilities

CapabilityDescriptionRequired Scopes
x.tweet.readRead tweetstweet.read, users.read
x.tweet.writePost tweetstweet.read, tweet.write, users.read
x.user.readRead user profilesusers.read
x.follow.readRead followers/followingfollows.read, users.read
x.follow.writeFollow/unfollow usersfollows.write, users.read
x.dm.readRead direct messagesdm.read, users.read
x.dm.writeSend direct messagesdm.write, users.read
x.like.readRead liked tweetslike.read, users.read
x.like.writeLike/unlike tweetslike.write, users.read

Using in apps

Declare X.com requirements in your app:

yaml
1requirements:2  integrations:3    - key: x.tweet.write4      description: Post automated tweets5 6    - key: x.dm.read7      description: Read incoming DMs8      optional: true

At runtime, your app receives:

bash
1X_ACCESS_TOKEN=oauth2-access-token2X_ACCESS_TOKEN_EXPIRES_AT=2024-01-15T10:30:00Z

Example: Post a tweet

python
1import tweepy2import os3 4# OAuth 2.0 user context5client = tweepy.Client(bearer_token=os.environ["X_ACCESS_TOKEN"])6 7client.create_tweet(text="Hello from my AI agent! 🤖")

Rate Limits

X.com has strict rate limits. Free tier includes:

EndpointLimit
POST tweets50/day
GET tweets100/month
GET users100/month

For higher limits, consider X's Basic or Pro tiers.


Security

  • Your credentials — API keys are encrypted at rest
  • Scoped access — OAuth 2.0 with PKCE for secure authorization
  • Revocable — revoke access from X's app settings or in inference.sh

Troubleshooting

"Callback URL mismatch"

  • Ensure the callback URL in your X app settings matches exactly:
    • Production: https://app.inference.sh/settings/secrets/oauth/x
    • The URL is case-sensitive and must include the /x provider suffix

"Rate limit exceeded"

  • Check your X Developer dashboard for current usage
  • Consider upgrading your X API tier
  • Space out requests in your agent logic

"Invalid credentials"

  • Verify your API Key, API Secret, Client ID, and Client Secret
  • Make sure you copied the full values without extra spaces
  • Regenerate credentials if needed

"App not approved"

  • Some X API features require app approval
  • Check the Developer Portal for any pending reviews

Callback URLs

Each provider has its own callback URL under the settings path:

EnvironmentCallback URL
Productionhttps://app.inference.sh/settings/secrets/oauth/x
Staginghttps://app.staging.inference.sh/settings/secrets/oauth/x
Local devhttp://localhost:3000/settings/secrets/oauth/x

You can add multiple callback URLs in your X app settings to support different environments.


Next

Back to Integrations OverviewSlack Integration

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.