diff --git a/.github/ISSUE_TEMPLATE/api-sorunu.yml b/.github/ISSUE_TEMPLATE/api-sorunu.yml new file mode 100644 index 0000000..10b27ec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/api-sorunu.yml @@ -0,0 +1,28 @@ +name: 🐞 API sorunu +description: Bir uç noktada beklenmeyen davranış bildir +labels: ["api"] +body: + - type: input + id: uc + attributes: + label: Uç nokta + placeholder: "ör. POST /api/v1/chat" + validations: + required: true + - type: textarea + id: istek + attributes: + label: İstek gövdesi + description: API anahtarını ASLA paylaşma. + render: json + - type: textarea + id: yanit + attributes: + label: Aldığın yanıt (durum kodu + gövde) + render: json + validations: + required: true + - type: textarea + id: beklenen + attributes: + label: Ne bekliyordun? diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..35dd505 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: 🔑 API anahtarı al + url: https://www.numexai.com.tr/api + about: 100.000 token hediye ile başla. + - name: 💳 Hesap / ödeme / fatura + url: mailto:destek@numexai.com.tr + about: Hesaba özel konular için e-posta gönder. diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..3ceefa5 --- /dev/null +++ b/README.en.md @@ -0,0 +1,61 @@ +
+ +Numex API + +# Numex API + +### Add Turkish-first AI to your apps. + +[🇹🇷 Türkçe](README.md) · 🇬🇧 **English** + +
+ +--- + +The Numex API gives you [Numex AI](https://numexai.com.tr)'s models — wrapped in a pipeline that turns +every answer into natural, high-quality Turkish. Chat, agentic tool use, vision/OCR, image generation, +embeddings and web search behind one key. **100,000 free tokens** on sign-up, no card required. + +## Quick start + +```bash +curl https://www.numexai.com.tr/api/v1/chat \ + -H "Authorization: Bearer $NUMEX_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"message":"Merhaba!","history":[],"maxOutputTokens":512}' +``` + +→ `{ "success": true, "answer": "...", "modelLabel": "Numex Pro", "usage": { ... } }` + +Auth: `Authorization: Bearer nx_live_...` or `x-api-key: nx_live_...`. Keys are shown once; rotate +them from the Numex dashboard. Never ship a key in browser code. + +## Models + +| Model | Context | Max out | Notes | Input / 1M | Output / 1M | +|---|---|---|---|---|---| +| `numex-pro` | 128K | 4K | Most capable; vision, function calling | ₺30 | ₺250 | +| `numex-fast` | 32K | 4K | ~3× faster, cheapest | ₺15 | ₺30 | +| `numex-think` | 128K | 8K | Deep reasoning (chain-of-thought) | ₺45 | ₺90 | +| `numex-code` | 64K | 8K | Code, 25+ languages | ₺30 | ₺85 | +| `numex-vision` | — | — | Image → text, OCR | ₺100 per image | — | + +## Endpoints (`https://www.numexai.com.tr/api/v1`) + +`POST /chat` · `POST /chat/stream` · `POST /chat/agent` (tools with `input_schema`) · `POST /vision` · +`POST /images/generations` · `POST /embeddings` (≤128 texts) · `POST /search` · `GET /models` · +`GET /features` · `GET /usage` + +Full reference (Turkish, with request/response examples): [docs/uc-noktalar.md](docs/uc-noktalar.md) + +## Pricing & limits + +Pay-as-you-go token packs that **never expire**: Starter ₺499 (5M) · Growth ₺1,499 (20M) · +Scale ₺3,499 (50M). Rate limits scale automatically with spend: Free 10 req/min → Tier 3 500 req/min. + +## SDK & examples + +- Node.js/TypeScript: [numex-sdk](https://github.com/mobilcep/numex-sdk) +- Python, cURL and an embeddings-based semantic search demo: [`ornekler/`](ornekler/) + +Support: **destek@numexai.com.tr** diff --git a/README.md b/README.md index 02eb0bc..91d4710 100644 --- a/README.md +++ b/README.md @@ -1 +1,246 @@ -# numex-api \ No newline at end of file +
+ +Numex API — Uygulamalarına Türkçe AI gücü kat + +# Numex API + +### Uygulamalarına Türkçe AI gücü kat. + +**Tek API ile sohbet, kod, görsel analiz, embedding ve web araması — Türkçe'ye özel.** + +[![Base URL](https://img.shields.io/badge/base-numexai.com.tr%2Fapi%2Fv1-00C9A7?style=for-the-badge)](https://www.numexai.com.tr/api) +[![Hediye](https://img.shields.io/badge/ilk_kayıtta-100.000_token-0A1628?style=for-the-badge)](https://www.numexai.com.tr/api) +[![SDK](https://img.shields.io/badge/SDK-numex--sdk-0A1628?style=for-the-badge)](https://github.com/mobilcep/numex-sdk) + +🇹🇷 Türkçe · [🇬🇧 English](README.en.md) + +
+ +--- + +Numex API; [Numex AI](https://numexai.com.tr)'ın Türkçe'ye özel **Pipeline** motorundan geçen +modellerini kendi uygulamana bağlamanın yoludur. Ham bir model sarmalayıcısı değil: her yanıt Türkçe +düzeltme, ton ve kalite kontrol katmanlarından geçer. + +> 📌 Bu depo Numex API'nin **dokümantasyon, örnek kod ve topluluk** deposudur. +> Anahtar almak için: [numexai.com.tr/api](https://www.numexai.com.tr/api). + +## 📑 İçindekiler + +- [Hızlı başlangıç](#-hızlı-başlangıç) +- [Kimlik doğrulama](#-kimlik-doğrulama) +- [Modeller](#-modeller) +- [Uç noktalar](#-uç-noktalar) +- [Fiyatlandırma](#-fiyatlandırma) +- [Kullanım limitleri](#-kullanım-limitleri) +- [Hatalar](#️-hatalar) +- [SDK ve örnekler](#-sdk-ve-örnekler) +- [Destek](#-destek) + +--- + +## ⚡ Hızlı başlangıç + +**1.** [numexai.com.tr/api](https://www.numexai.com.tr/api) → **Ücretsiz API Anahtarı Al** +(Google/GitHub ile giriş; ilk kayıtta **100.000 token** hediye, kart gerekmez). + +**2.** Anahtarını kopyala. `nx_live_` ile başlar ve **yalnızca bir kez** gösterilir. + +**3.** İlk isteğini at: + +```bash +curl https://www.numexai.com.tr/api/v1/chat \ + -H "Authorization: Bearer $NUMEX_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"message":"Merhaba, nasılsın?","history":[],"maxOutputTokens":512}' +``` + +```json +{ + "success": true, + "answer": "Merhaba! İyiyim, teşekkür ederim. Sana nasıl yardımcı olabilirim?", + "modelProfile": "pro", + "modelLabel": "Numex Pro", + "usage": { + "estimatedInputTokens": 5, + "estimatedOutputTokens": 18, + "estimatedTotalTokens": 23, + "billedTokens": 23, + "multiplier": 1 + } +} +``` + +
+Python + +```python +import os, requests + +r = requests.post( + "https://www.numexai.com.tr/api/v1/chat", + headers={"Authorization": f"Bearer {os.environ['NUMEX_API_KEY']}"}, + json={"message": "Python'da fibonacci fonksiyonu yaz", "history": [], "maxOutputTokens": 1024}, +) +print(r.json().get("answer", "")) +``` +
+ +
+JavaScript (fetch) + +```javascript +const res = await fetch('https://www.numexai.com.tr/api/v1/chat', { + method: 'POST', + headers: { + Authorization: `Bearer ${process.env.NUMEX_API_KEY}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ message: 'React ile todo app yaz', history: [], maxOutputTokens: 2048 }), +}); +const data = await res.json(); +console.log(data.answer); +``` +
+ +
+Node.js SDK + +```bash +npm install numexcodex-sdk +``` + +```javascript +const { Numex } = require('numexcodex-sdk'); +const numex = new Numex({ + apiKey: process.env.NUMEX_API_KEY, + baseURL: 'https://www.numexai.com.tr/api/v1', +}); +const r = await numex.chat.completions.create({ + messages: [{ role: 'user', content: 'Merhaba!' }], +}); +console.log(r.answer); +``` +→ [github.com/mobilcep/numex-sdk](https://github.com/mobilcep/numex-sdk) +
+ +Daha fazla hazır örnek: [`ornekler/`](ornekler/) + +--- + +## 🔐 Kimlik doğrulama + +İki başlıktan biri yeterli: + +```http +Authorization: Bearer nx_live_... +``` +```http +x-api-key: nx_live_... +``` + +- Anahtarı **sunucunda** sakla; tarayıcı koduna, mobil uygulamaya ya da herkese açık depoya koyma. +- Panelden anahtarı **döndürebilir** (rotate), devre dışı bırakabilir ya da silebilirsin. +- Anahtar yoksa: `401 {"error":"x-api-key zorunludur","code":"missing_api_key"}` + +--- + +## 🧠 Modeller + +| Model | Rol | Bağlam | Maks. çıktı | Yetenekler | Input / 1M | Output / 1M | +|---|---|---|---|---|---|---| +| ⚡ `numex-pro` | **En popüler.** Akıl yürütme, yaratıcılık, Türkçe'de en yüksek başarım | 128K | 4K | Vision ✓ · Function calling ✓ | ₺30 | ₺250 | +| 🚀 `numex-fast` | Hız ve maliyet odaklı: günlük görevler, sınıflandırma | 32K | 4K | Vision ✓ · ~3× hızlı | ₺15 | ₺30 | +| 🧠 `numex-think` | Derin akıl yürütme: matematik, mantık, strateji | 128K | 8K | Chain-of-thought | ₺45 | ₺90 | +| 💻 `numex-code` | Kod: tamamlama, bug fix, review, refactor | 64K | 8K | 25+ programlama dili | ₺30 | ₺85 | +| 🖼️ `numex-vision` | Görsel anlama, resim açıklama, OCR | — | — | Image → Text · OCR · Türkçe | ₺100 / görsel analizi | — | + +Model, istekte `model` (veya `modelProfile`) alanıyla seçilir. Kullanılabilen modeller planına göre +değişir; güncel liste için `GET /models`, açık yetenekler için `GET /features`. + +--- + +## 📚 Uç noktalar + +**Base URL:** `https://www.numexai.com.tr/api/v1` + +| Yöntem | Yol | Açıklama | Ayrıntı | +|---|---|---|---| +| `POST` | `/chat` | Sohbet yanıtı | [→](docs/uc-noktalar.md#post-chat) | +| `POST` | `/chat/stream` | Akışlı sohbet (SSE) | [→](docs/uc-noktalar.md#post-chatstream) | +| `POST` | `/chat/agent` | Araç kullanan, çok adımlı ajan (function calling) | [→](docs/uc-noktalar.md#post-chatagent) | +| `POST` | `/vision` | Görsel analizi / OCR | [→](docs/uc-noktalar.md#post-vision) | +| `POST` | `/images/generations` | Görsel üretimi | [→](docs/uc-noktalar.md#post-imagesgenerations) | +| `POST` | `/embeddings` | Metin vektörleri (en fazla 128 metin) | [→](docs/uc-noktalar.md#post-embeddings) | +| `POST` | `/search` | Web araması + kaynaklar | [→](docs/uc-noktalar.md#post-search) | +| `GET` | `/models` | Modeller | [→](docs/uc-noktalar.md#get-models) | +| `GET` | `/features` | Hesabında açık yetenekler | [→](docs/uc-noktalar.md#get-features) | +| `GET` | `/usage` · `/usage/history` | Token kullanımı | [→](docs/uc-noktalar.md#hesap-ve-kullanım) | +| `GET` | `/me` · `/account` | Hesap ve bakiye | [→](docs/uc-noktalar.md#hesap-ve-kullanım) | + +👉 **Tam referans: [docs/uc-noktalar.md](docs/uc-noktalar.md)** + +--- + +## 💳 Fiyatlandırma + +**Token paketleri — kullandıkça öde.** Numex uygulama aboneliğinden bağımsızdır. Tokenler +**kalıcıdır**: ay sonunda sıfırlanmaz, kullanmadıkça devreder. Her çağrıda yalnızca kullanılan token +bakiyeden düşer. + +| Paket | Fiyat | Token | Yaklaşık | Öne çıkanlar | +|---|---|---|---|---| +| **Starter API** | ₺499 | 5.000.000 | ~2.500 sohbet mesajı · ~2 CLI projesi | Chat erişimi, kullanım metrikleri | +| **Growth API** ⭐ | ₺1.499 | 20.000.000 | ~10.000 mesaj · ~10 CLI projesi | Premium model havuzu, öncelikli kuyruk, aşım ₺0,10 / 1K | +| **Scale API** | ₺3.499 | 50.000.000 | ~25.000 mesaj · ~25 CLI projesi | Kurumsal destek & SLA, gelişmiş gözlemlenebilirlik, aşım ₺0,075 / 1K | + +Model bazlı birim fiyatlar yukarıdaki [Modeller](#-modeller) tablosunda. +*Güncel fiyatlar için [numexai.com.tr/api](https://www.numexai.com.tr/api) esastır.* + +## 🚦 Kullanım limitleri + +Toplam harcaman arttıkça **tier**'in otomatik yükselir: + +| Tier | İstek / dk | Token / dk | Günlük limit | Koşul | +|---|---|---|---|---| +| Free | 10 | 20K | 100K token | Ödeme bilgisi ekle | +| Tier 1 | 60 | 100K | Sınırsız | ₺250+ harcama | +| Tier 2 | 200 | 400K | Sınırsız | ₺2.500+ harcama | +| Tier 3 | 500 | 1M | Sınırsız | ₺10.000+ harcama | +| Enterprise | Özel | Özel | Sınırsız | İletişime geç | + +## ⚠️ Hatalar + +| Kod | Anlamı | Örnek gövde | +|---|---|---| +| `400` | Eksik / hatalı parametre | `{"error":"message zorunludur"}` | +| `401` | Anahtar yok veya geçersiz | `{"error":"x-api-key zorunludur","code":"missing_api_key"}` | +| `402` | Token bakiyesi yetersiz | `{"error":"Yetersiz token bakiyesi","code":"insufficient_tokens","tokenBalance":0}` | +| `429` | Hız limiti aşıldı | Bekleyip üstel geri çekilmeyle tekrar dene | +| `500` / `502` | Sunucu veya dış servis hatası | Kısa bir süre sonra tekrar dene | + +--- + +## 🧰 SDK ve örnekler + +| | | +|---|---| +| 🟩 **Node.js / TypeScript** | [numex-sdk](https://github.com/mobilcep/numex-sdk) — `npm i numexcodex-sdk` | +| 🐍 **Python** | Resmî SDK henüz yok; [`ornekler/python_sohbet.py`](ornekler/python_sohbet.py) | +| 🧪 **cURL** | [`ornekler/curl.sh`](ornekler/curl.sh) | +| ⌨️ **CLI** | [Numex Codex](https://github.com/mobilcep/numex-codex) — `npm i -g @numexai/cli` | + +## 📬 Destek + +- 📧 **destek@numexai.com.tr** — hafta içi 09:00–18:00 +- 📞 **0216 311 53 58** — acil durumlar ve kurumsal, hafta içi 09:00–17:00 +- 🤖 Numex sohbetinde *"destek"* yaz — 7/24 +- 🐞 Dokümanda hata mı var? → [Issue aç](../../issues/new/choose) + +
+ +--- + +**Numex API** · [Numex Ailesi](https://www.numexai.com.tr/aile)'nin geliştirici kapısı · 🇹🇷 + +
diff --git a/docs/uc-noktalar.md b/docs/uc-noktalar.md new file mode 100644 index 0000000..fa645c1 --- /dev/null +++ b/docs/uc-noktalar.md @@ -0,0 +1,193 @@ +# 📚 Numex API — Uç Nokta Referansı + +**Base URL:** `https://www.numexai.com.tr/api/v1` +**Kimlik:** `Authorization: Bearer nx_live_...` veya `x-api-key: nx_live_...` +**Gövde:** `Content-Type: application/json` + +Tüm yapay zekâ uç noktaları çağrı başına token bakiyenden düşer; bakiye yetmezse `402 +insufficient_tokens` döner. + +--- + +## `POST /chat` + +Tek bir mesaj ve isteğe bağlı sohbet geçmişiyle yanıt üretir. Yanıt Numex **Pipeline**'ından geçer. + +| Alan | Tür | Zorunlu | Açıklama | +|---|---|---|---| +| `message` | string | ✅ | Kullanıcının mesajı | +| `history` | array | — | Önceki mesajlar: `[{ "role": "user"\|"assistant", "content": "..." }]` | +| `model` | string | — | `numex-pro`, `numex-fast`, `numex-think`, `numex-code` (planına göre) | +| `maxOutputTokens` | number | — | 32–8192, varsayılan 4096 | + +**İstek** +```json +{ + "message": "Bu fonksiyonu açıkla: const f = n => n < 2 ? n : f(n-1) + f(n-2)", + "history": [], + "model": "numex-code", + "maxOutputTokens": 1024 +} +``` + +**Yanıt `200`** +```json +{ + "success": true, + "answer": "Bu, özyinelemeli bir Fibonacci fonksiyonudur…", + "modelProfile": "code", + "modelLabel": "Numex Code", + "usage": { + "estimatedInputTokens": 24, + "estimatedOutputTokens": 180, + "estimatedTotalTokens": 204, + "billedTokens": 204, + "multiplier": 1 + } +} +``` + +--- + +## `POST /chat/stream` + +`/chat` ile aynı gövde; yanıt **Server-Sent Events** olarak parça parça gelir. + +```bash +curl -N https://www.numexai.com.tr/api/v1/chat/stream \ + -H "Authorization: Bearer $NUMEX_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"message":"Türkiye ekonomisi hakkında kısa bir analiz yaz"}' +``` + +> Not: Sitedeki örnekler şu an tam yanıt döndüren `/chat` kullanıyor; akışlı yanıta ihtiyacın yoksa +> `/chat` ile başla. + +--- + +## `POST /chat/agent` + +Araç kullanan (function calling), çok adımlı ajan çağrısı. OpenAI tarzı `messages` dizisi alır. + +| Alan | Tür | Zorunlu | Açıklama | +|---|---|---|---| +| `messages` | array | ✅ | `[{ "role": "system"\|"user"\|"assistant"\|"tool", "content": ... }]` | +| `tools` | array | — | JSON Schema ile tanımlı araçlar | +| `system` | string | — | Sistem talimatı | +| `mode` / `agentMode` | string | — | Ajan modu | +| `model` | string | — | Model | +| `maxOutputTokens` | number | — | Çıktı sınırı | + +```json +{ + "messages": [{ "role": "user", "content": "İstanbul'da yarın hava nasıl olacak?" }], + "tools": [{ + "name": "hava_durumu", + "description": "Bir şehir için hava tahmini döner", + "input_schema": { + "type": "object", + "properties": { "sehir": { "type": "string" }, "gun": { "type": "string" } }, + "required": ["sehir"] + } + }] +} +``` + +--- + +## `POST /vision` + +Görsel analizi, açıklama ve OCR. + +| Alan | Tür | Zorunlu | Açıklama | +|---|---|---|---| +| `image` | string | ✅ | Görsel URL'si **veya** Base64 | +| `prompt` | string | — | Görselle ilgili soru / talimat | + +```json +{ "image": "https://ornek.com/fatura.jpg", "prompt": "Bu faturadaki toplam tutarı ve tarihi çıkar" } +``` + +Hatalar: `400 image alanı (URL veya Base64) zorunludur` · `400 Görsel indirilemedi: …` + +--- + +## `POST /images/generations` + +Metinden görsel üretir. + +```json +{ "prompt": "Kapadokya'da gün doğumu, sıcak hava balonları, sinematik" } +``` + +Hata: `400 Geçersiz görsel isteği` + +--- + +## `POST /embeddings` + +Metinleri vektöre çevirir — anlamsal arama, RAG, sınıflandırma, kümeleme için. + +| Alan | Tür | Zorunlu | Açıklama | +|---|---|---|---| +| `input` | string \| string[] | ✅ | Tek metin ya da metin dizisi (`inputs`, `texts` da kabul edilir) | + +- Tek istekte **en fazla 128 metin**. + +```json +{ "input": ["Kira sözleşmesi nasıl feshedilir?", "Depozito iadesi ne zaman yapılır?"] } +``` + +**Yanıt:** `{ "success": true, "embeddings": [[0.012, -0.08, …], […]], "dimensions": , "count": 2 }` +(`dimensions` modele göre değişir.) + +Hatalar: `400 input (metin veya metin dizisi) zorunludur` · `400 En fazla 128 metin gönderilebilir` + +--- + +## `POST /search` + +Web'de arar, kaynakları başlık, bağlantı ve kısa özetle döner. + +| Alan | Tür | Zorunlu | Açıklama | +|---|---|---|---| +| `query` | string | ✅ | Arama sorgusu (`sorgu` da kabul edilir) | +| `num` | number | — | Kaynak sayısı, 1–10 (varsayılan 5; `limit` da kabul edilir) | + +```json +{ "query": "2026 asgari ücret", "num": 5 } +``` + +Yanıttaki her kaynak: `{ "title": "...", "link": "...", "snippet": "..." }` + +Hatalar: `400 query zorunludur` · `502 Web araması şu an yapılamadı.` + +--- + +## `GET /models` + +Hesabının kullanabildiği modelleri listeler. + +## `GET /features` + +Anahtarına bağlı planda hangi yeteneklerin açık olduğunu döner: `{ "success": true, "features": {...} }`. +Entegrasyona başlamadan önce kontrol etmen önerilir. + +--- + +## Hesap ve kullanım + +| Yöntem | Yol | Açıklama | +|---|---|---| +| `GET` | `/me` · `/account` | Hesap bilgisi ve token bakiyesi | +| `GET` | `/usage` | Güncel kullanım | +| `GET` | `/usage/history` | Kullanım geçmişi | +| `GET` | `/payments` | Ödeme geçmişi | +| `GET` | `/me/models` | Tercih edilebilir modeller | +| `POST` | `/me/preferred-model` | Varsayılan modeli ayarla | +| `POST` | `/me/test-key` | Anahtarı test et | + +Anahtar yönetimi (oluşturma, döndürme, silme) ve paket satın alma **Numex paneli** üzerinden yapılır. + +--- +← [Ana sayfa](../README.md) diff --git a/gorseller/api-banner.png b/gorseller/api-banner.png new file mode 100644 index 0000000..f79ea41 Binary files /dev/null and b/gorseller/api-banner.png differ diff --git a/gorseller/api-sayfa.png b/gorseller/api-sayfa.png new file mode 100644 index 0000000..9a2a215 Binary files /dev/null and b/gorseller/api-sayfa.png differ diff --git a/ornekler/__pycache__/python_sohbet.cpython-311.pyc b/ornekler/__pycache__/python_sohbet.cpython-311.pyc new file mode 100644 index 0000000..9505881 Binary files /dev/null and b/ornekler/__pycache__/python_sohbet.cpython-311.pyc differ diff --git a/ornekler/curl.sh b/ornekler/curl.sh new file mode 100755 index 0000000..28a35a0 --- /dev/null +++ b/ornekler/curl.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Numex API — cURL örnekleri +# Kullanım: export NUMEX_API_KEY=nx_live_... && bash curl.sh +set -euo pipefail +BASE="https://www.numexai.com.tr/api/v1" +AUTH="Authorization: Bearer ${NUMEX_API_KEY:?NUMEX_API_KEY tanımlı değil}" + +echo "== Sohbet" +curl -s "$BASE/chat" -H "$AUTH" -H "Content-Type: application/json" \ + -d '{"message":"Bana 3 maddede Numex nedir anlat","history":[],"maxOutputTokens":512}' +echo + +echo "== Web araması" +curl -s "$BASE/search" -H "$AUTH" -H "Content-Type: application/json" \ + -d '{"query":"yapay zeka KVKK","num":3}' +echo + +echo "== Embedding" +curl -s "$BASE/embeddings" -H "$AUTH" -H "Content-Type: application/json" \ + -d '{"input":["merhaba dünya","selam evren"]}' | head -c 300 +echo + +echo "== Açık yetenekler" +curl -s "$BASE/features" -H "$AUTH" +echo diff --git a/ornekler/node_rag.mjs b/ornekler/node_rag.mjs new file mode 100644 index 0000000..5f19afc --- /dev/null +++ b/ornekler/node_rag.mjs @@ -0,0 +1,35 @@ +// Numex API — embeddings ile basit anlamsal arama (RAG'in "R"si) +// Kullanım: NUMEX_API_KEY=nx_live_... node node_rag.mjs +const BASE = 'https://www.numexai.com.tr/api/v1'; +const headers = { + Authorization: `Bearer ${process.env.NUMEX_API_KEY}`, + 'Content-Type': 'application/json', +}; + +const belgeler = [ + 'Kira sözleşmesi, kiracı tarafından 15 gün önceden yazılı bildirimle feshedilebilir.', + 'Depozito, taşınmaz hasarsız teslim edildiğinde 30 gün içinde iade edilir.', + 'Aidat ödemeleri her ayın 5\'ine kadar yönetim hesabına yatırılır.', +]; + +async function embed(input) { + const r = await fetch(`${BASE}/embeddings`, { method: 'POST', headers, body: JSON.stringify({ input }) }); + if (!r.ok) throw new Error(`${r.status} ${await r.text()}`); + const { embeddings } = await r.json(); // { embeddings: number[][], dimensions, count } + return embeddings; +} + +const kosinus = (a, b) => { + let d = 0, na = 0, nb = 0; + for (let i = 0; i < a.length; i++) { d += a[i] * b[i]; na += a[i] ** 2; nb += b[i] ** 2; } + return d / (Math.sqrt(na) * Math.sqrt(nb)); +}; + +const soru = 'Depozitomu ne zaman geri alırım?'; +const [soruVek, ...belgeVek] = await embed([soru, ...belgeler]); +const sirali = belgeler + .map((metin, i) => ({ metin, skor: kosinus(soruVek, belgeVek[i]) })) + .sort((a, b) => b.skor - a.skor); + +console.log(`Soru: ${soru}\n`); +for (const { metin, skor } of sirali) console.log(`${skor.toFixed(3)} ${metin}`); diff --git a/ornekler/python_sohbet.py b/ornekler/python_sohbet.py new file mode 100644 index 0000000..911edbc --- /dev/null +++ b/ornekler/python_sohbet.py @@ -0,0 +1,40 @@ +"""Numex API — Python ile çok turlu sohbet örneği. + +Kurulum: pip install requests +Kullanım: NUMEX_API_KEY=nx_live_... python python_sohbet.py +""" +import os +import requests + +BASE = "https://www.numexai.com.tr/api/v1" +HEADERS = {"Authorization": f"Bearer {os.environ['NUMEX_API_KEY']}"} + + +def sor(mesaj, gecmis, model="numex-pro"): + r = requests.post( + f"{BASE}/chat", + headers=HEADERS, + json={"message": mesaj, "history": gecmis, "model": model, "maxOutputTokens": 1024}, + timeout=120, + ) + if r.status_code == 402: + raise SystemExit("Token bakiyesi yetersiz — numexai.com.tr/api üzerinden paket yükleyin.") + r.raise_for_status() + return r.json() + + +def main(): + gecmis = [] + print("Numex ile sohbet (çıkmak için boş satır)\n") + while True: + mesaj = input("Sen: ").strip() + if not mesaj: + break + yanit = sor(mesaj, gecmis) + cevap = yanit.get("answer", "") + print(f"\nNumex ({yanit.get('modelLabel', '')}): {cevap}\n") + gecmis += [{"role": "user", "content": mesaj}, {"role": "assistant", "content": cevap}] + + +if __name__ == "__main__": + main()