Skip to main content

Authentication

GigaReels uses API keys to authenticate requests. You can get your API key from the dashboard or use our CLI for automatic authentication. The easiest way to authenticate is using the CLI login command:
npx @gigareels/sdk login
This command will:
  1. Open your browser to the GigaReels authentication page
  2. Authenticate with your existing account or sign up
  3. Generate an API key automatically
  4. Store credentials locally in ~/.gigareels/credentials.json
CLI authentication is perfect for development and personal projects. The SDK will automatically use stored credentials.

Local Development

For local development, you can authenticate against a local server:
npx @gigareels/sdk login --local
This connects to http://localhost:3000 instead of the production server.

Check Authentication Status

You can check if you’re already authenticated:
import { GigaReels } from "@gigareels/sdk";

const isLoggedIn = await GigaReels.isLoggedIn();
if (isLoggedIn) {
	console.log("✅ Already authenticated");
} else {
	console.log("❌ Please run 'npx @gigareels/sdk login'");
}

Manual API Key Authentication

For production applications, you should use manual API key authentication:

1. Get Your API Key

  1. Go to your GigaReels Dashboard
  2. Navigate to SettingsAPI Keys
  3. Click Generate New API Key
  4. Copy your API key and store it securely
Keep your API key secure: Never commit API keys to version control or expose them in client-side code.

2. Initialize the Client

import { GigaReels } from "@gigareels/sdk";

const client = new GigaReels({
	apiKey: "your-api-key-here",
	baseUrl: "https://gigareels.com", // Optional, defaults to production
});

Environment Variables

For production applications, use environment variables to store your API key:
# .env
GIGAREELS_API_KEY=your-api-key-here
import { GigaReels } from "@gigareels/sdk";

const client = new GigaReels({
	apiKey: process.env.GIGAREELS_API_KEY,
});

Authentication Methods Comparison

Pros:
  • ✅ Automatic credential management
  • ✅ Perfect for development
  • ✅ Browser-based login
  • ✅ No manual API key handling
Cons:
  • ❌ Not suitable for production servers
  • ❌ Requires interactive login
Best for: Development, personal projects, local testing

SDK Initialization Patterns

Pattern 1: Auto-Detection

The SDK can automatically detect stored credentials:
import { GigaReels } from "@gigareels/sdk";

// SDK automatically uses stored credentials from CLI login
const client = new GigaReels();
If no stored credentials are found, the SDK will throw an error with helpful instructions.

Pattern 2: Explicit Configuration

import { GigaReels } from "@gigareels/sdk";

const client = new GigaReels({
	apiKey: process.env.GIGAREELS_API_KEY,
	baseUrl: "https://gigareels.com", // Optional
});

Pattern 3: Conditional Authentication

import { GigaReels } from "@gigareels/sdk";

async function createClient() {
	// Check if CLI credentials exist
	const isLoggedIn = await GigaReels.isLoggedIn();

	if (isLoggedIn) {
		// Use stored credentials
		return new GigaReels();
	} else if (process.env.GIGAREELS_API_KEY) {
		// Use environment variable
		return new GigaReels({
			apiKey: process.env.GIGAREELS_API_KEY,
		});
	} else {
		throw new Error("Please authenticate with 'npx @gigareels/sdk login' or set GIGAREELS_API_KEY");
	}
}

const client = await createClient();

Authentication Errors

Common authentication errors and solutions:
Error: No API key provided and no stored credentials foundSolution:
npx @gigareels/sdk login
Or provide an API key manually:
const client = new GigaReels({ apiKey: "your-key" });
Error: Invalid API key or 401 UnauthorizedSolutions:
  1. Check your API key is correct
  2. Regenerate your API key in the dashboard
  3. Ensure you’re using the right base URL
npx @gigareels/sdk logout
npx @gigareels/sdk login
Error: Authentication expiredSolution: Re-authenticate with the CLI:
npx @gigareels/sdk logout
npx @gigareels/sdk login

Security Best Practices

🔒 Secure Storage

  • Never commit API keys to version control - Use environment variables for production - Rotate API keys regularly - Store keys in secure secret management systems

🛡️ Access Control

  • Use separate API keys for different environments - Implement proper error handling - Monitor API key usage - Revoke unused API keys

🌐 Network Security

  • Always use HTTPS - Validate SSL certificates - Implement request timeout - Use proper CORS settings

📝 Logging

  • Log authentication events - Never log API keys - Monitor failed authentication attempts - Set up alerts for suspicious activity

Next Steps

1

Authenticate

Choose your preferred authentication method and get your API key set up
2

Test Connection

Make a simple API call to verify your authentication is working
3

Start Building

Explore the Render Types to start generating content

Need Help?

If you’re having trouble with authentication, check our troubleshooting guide or contact albert@gigareels.com.