Skip to content

Rahyanaco/github-examples

Repository files navigation

Rahyana AI API Examples - Complete Developer Guide

This directory contains comprehensive, production-ready examples for using the Rahyana AI API across multiple programming languages. Build powerful AI applications with our RESTful API, OpenAI-compatible endpoints, and advanced AI models including GPT-5, GPT-4o, and more.

🚀 Quick Start - Get Started in 5 Minutes

  1. Get your API key from rahyana.ir - Free tier available
  2. Choose your programming language from our comprehensive examples
  3. Replace YOUR_API_KEY_HERE with your actual API key
  4. Run the examples and start building AI-powered applications!

Why Choose Rahyana AI API?

  • OpenAI Compatible - Drop-in replacement for OpenAI API
  • Multiple AI Models - GPT-5, GPT-4o, Claude, Gemini, and more
  • Advanced Features - Image processing, audio analysis, web search
  • Production Ready - High availability, rate limiting, monitoring
  • Developer Friendly - Comprehensive documentation and examples

📁 Available Programming Languages

  • JavaScript - Complete examples with all API endpoints and real-world projects
  • Python - Python examples with requests library and AI applications
  • cURL - Command-line examples for testing and automation
  • TypeScript - (Coming soon) - Type-safe examples for enterprise applications
  • PHP - PHP examples with image generation and WordPress integration guide
  • Ruby - (Coming soon) - Ruby on Rails and Sinatra examples
  • Go - (Coming soon) - High-performance microservices and APIs
  • Java - (Coming soon) - Spring Boot and enterprise applications
  • C# - (Coming soon) - .NET Core and ASP.NET integration

🎯 API Endpoints Covered

Chat Completions (/api/v1/chat/completions)

  • ✅ Basic text chat
  • ✅ Streaming responses
  • ✅ Image generation (PHP, JavaScript, Python)
  • ✅ Image analysis
  • ✅ Audio processing
  • ✅ PDF processing
  • ✅ Web search
  • ✅ Tool calling (Function calling)
  • ✅ JSON mode

Legacy Completions (/api/v1/completions)

  • ✅ Text completion
  • ✅ Streaming completion
  • ✅ Code completion
  • ✅ Creative writing

Models (/api/v1/models)

  • ✅ List available models
  • ✅ Filter by capabilities
  • ✅ Model information

🤖 Supported AI Models

All examples include the most popular and powerful AI models:

OpenAI Models

  • GPT-5 - Latest OpenAI model with advanced reasoning
  • GPT-4o - Multimodal capabilities (text, image, audio)
  • GPT-4o-mini - Fast and efficient for high-volume applications
  • GPT-4 Turbo - High-performance model for complex tasks

Anthropic Models

  • Claude Sonnet 4.5 - Advanced reasoning and analysis
  • Claude Haiku - Fast and efficient for simple tasks

Google Models

  • Gemini 2.0 Flash - Google's latest multimodal model
  • Gemini Pro - Advanced reasoning and code generation

Specialized Models

  • Code Generation - Specialized models for programming tasks
  • Image Analysis - Computer vision and image understanding
  • Audio Processing - Speech recognition and audio analysis

🌟 Key Features & Benefits

🚀 Production Ready

  • Enterprise-grade examples using rahyana.ir base URL
  • Scalable architecture for high-traffic applications
  • Error handling and rate limiting built-in
  • Monitoring and logging capabilities

🔒 Security First

  • No real API keys in published examples
  • Secure authentication with Bearer tokens
  • Input validation and sanitization
  • HTTPS-only communication

🌍 Multi-Language Support

  • JavaScript/Node.js - Complete with real-world projects
  • Python - Data science and AI applications
  • cURL - Command-line automation and testing
  • PHP - Image generation and WordPress integration
  • TypeScript, Ruby, Go, Java, C# - Coming soon

📚 Comprehensive Coverage

  • All API endpoints - Chat, Completions, Models
  • Advanced features - Image processing, audio analysis, web search
  • Real-world projects - Content generation, chatbots, code assistants
  • Best practices - Error handling, optimization, security

🎯 Developer Experience

  • Well documented - Detailed explanations and comments
  • Farsi support - All explanations in Farsi for Persian developers
  • Copy-paste ready - Working examples you can use immediately
  • Modular design - Easy to integrate into existing projects
  • SEO Optimized - Examples include popular use cases

📖 Documentation

Each language directory contains:

  • README.fa.md - Farsi documentation with detailed explanations
  • Working examples - Copy-paste ready code
  • Real-world use cases - Practical examples for common scenarios
  • Error handling - Proper error management
  • Best practices - Security and performance tips

🔧 Testing

For internal testing, use:

node test-with-real-key.js

Note: This file contains real API keys and should not be published.

📝 Usage Examples

JavaScript

const API_KEY = 'YOUR_API_KEY_HERE';
const BASE_URL = 'https://rahyana.ir/api/v1';

// Basic chat
const response = await fetch(`${BASE_URL}/chat/completions`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'openai/gpt-5',
    messages: [{ role: 'user', content: 'Hello!' }]
  })
});

Python

import requests

API_KEY = 'YOUR_API_KEY_HERE'
BASE_URL = 'https://rahyana.ir/api/v1'

response = requests.post(f"{BASE_URL}/chat/completions", 
  headers={'Authorization': f'Bearer {API_KEY}'},
  json={'model': 'openai/gpt-5', 'messages': [{'role': 'user', 'content': 'Hello!'}]}
)

cURL

curl -X POST "https://rahyana.ir/api/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-5", "messages": [{"role": "user", "content": "Hello!"}]}'

🛡️ Security

  • All examples use placeholder API keys
  • No sensitive information in published code
  • Production-ready configurations
  • Proper error handling

📞 Support

🚀 Popular Use Cases & Applications

AI-Powered Applications

  • Chatbots & Virtual Assistants - Customer support, sales, and personal assistants
  • Content Generation - Blog posts, social media, marketing materials
  • Code Generation - Automated coding, debugging, and documentation
  • Image Analysis - Computer vision, object detection, image classification
  • Audio Processing - Speech recognition, transcription, voice synthesis
  • Web Search Integration - Real-time information retrieval and analysis

Industry Applications

  • E-commerce - Product descriptions, customer support, recommendation systems
  • Healthcare - Medical analysis, patient support, research assistance
  • Education - Personalized learning, tutoring, content creation
  • Finance - Risk analysis, fraud detection, customer service
  • Marketing - Campaign creation, content optimization, audience analysis

🔥 Trending Keywords & Technologies

  • OpenAI Alternative - Drop-in replacement for OpenAI API
  • GPT-5 Integration - Latest AI model capabilities
  • RESTful API - Standard HTTP-based API design
  • Machine Learning API - AI model access and integration
  • AI Development - Tools and frameworks for AI applications
  • Natural Language Processing - Text analysis and generation
  • Computer Vision - Image and video analysis
  • API Integration - Connecting AI services to applications

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Ready to build amazing AI applications? 🚀 Start with our examples and create something incredible!

About

Collection of code examples for Rahyana API in multiple programming languages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors