### GET / Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/segmenter.html Counts tokens for the provided content via a simple GET request. ```APIDOC ## GET / ### Description Counts the number of tokens in the provided content string. ### Method GET ### Endpoint https://segment.jina.ai/ ### Parameters #### Query Parameters - **content** (string) - Required - The text content to count tokens for. ### Response #### Success Response (200) - **num_tokens** (integer) - The total count of tokens in the content. - **num_chunks** (integer) - The number of chunks identified. - **chunk_positions** (array) - The positions of the chunks. - **chunks** (array) - The segmented text chunks. ``` -------------------------------- ### Send GET Request to Jina AI Search API Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/index-gen.txt Demonstrates how to send a GET request to the Jina AI search endpoint. Includes setting up the endpoint, headers, parameters, and data payload. Ensure you replace '' with your actual authentication token. ```python endpoint = f"https://s.jina.ai/When%20was%20Jina%20AI%20founded?" # Base endpoint, required headers = { "Accept": "application/json", # Response format, required "Authorization": "Bearer ", # Authentication token, required "Content-Type": "application/json", # Request body format, optional "X-Custom-Header": "value" # Example of a custom header, optional } params = { "param_key": "param_value", # Example URL parameter, optional } data = { "request_key": "request_value", # Example request body data, optional } response = requests.get(endpoint, headers=headers, params=params, json=data) # Sends a GET request ``` -------------------------------- ### Perform a Search Request Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/s.reader.html Examples of how to query the search endpoint using different programming languages. ```bash curl 'https://s.jina.ai/When%20was%20Jina%20AI%20founded?' \ -H "Accept: application/json" \ -H "Authorization: Bearer jina_74e70f6c60524b30811f57587baeece4EeJ603iFt-LCsemqEJHOJzLzgRnq" ``` ```javascript fetch('https://s.jina.ai/When%20was%20Jina%20AI%20founded?', { method: 'GET', headers: { "Authorization": "Bearer jina_74e70f6c60524b30811f57587baeece4EeJ603iFt-LCsemqEJHOJzLzgRnq", "Accept": "application/json" }, }) ``` -------------------------------- ### Segmenter API POST Response Example Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/segmenter.html Example of a successful response from the Segmenter API when requesting tokens and chunks, including token details and chunk positions. ```json { "num_tokens": 78, "tokenizer": "cl100k_base", "usage": { "tokens": 0 }, "num_chunks": 4, "chunk_positions": [ [ 3, 55 ], [55, 93 ], [ 93, 110 ], [ 110, 135 ] ], "tokens": [ [ [ "J", [ 41 ] ], [ "ina", [2259] ], [ " AI", [15592] ], [ ":", [25] ], [ " Your", [4718] ], [ " Search", [7694] ], [ " Foundation", [5114] ], [ ",", [11] ], [ " Super", [7445] ], [ "charged", [38061] ], [ "!", [0] ], [ " ", [11410] ], [ "🚀", [248, 222] ], [ "\n", [198] ], [ " ", [256] ] ], [ ``` -------------------------------- ### GET /s.jina.ai/{query} Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/s.reader.html Searches the web for a given query and returns URLs and content in an LLM-friendly format. ```APIDOC ## GET /s.jina.ai/{query} ### Description Searches the web for a query and returns results in clean, LLM-friendly text. ### Method GET ### Endpoint https://s.jina.ai/{query} ### Parameters #### Path Parameters - **query** (string) - Required - The search query string. ### Request Example curl 'https://s.jina.ai/When%20was%20Jina%20AI%20founded?' \ -H "Accept: application/json" \ -H "Authorization: Bearer " ### Response #### Success Response (200) - **code** (integer) - Status code - **status** (integer) - Internal status code - **data** (array) - List of search results #### Response Example { "code": 200, "status": 20000, "data": [ { "title": "Jina AI - Your Search Foundation, Supercharged." } ] } ``` -------------------------------- ### GET /https://{url} Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/r.reader.html Fetches the content of a specified URL and returns it in a structured format suitable for LLM consumption. ```APIDOC ## GET /https://{url} ### Description Fetches the content of a specified URL and returns it in a structured format. ### Method GET ### Endpoint https://r.jina.ai/{url} ### Parameters #### Path Parameters - **url** (string) - Required - The URL to be fetched and parsed. ### Request Example curl 'https://r.jina.ai/https://example.com' \ -H "Accept: application/json" \ -H "Authorization: Bearer " ### Response #### Success Response (200) - **code** (integer) - HTTP status code - **status** (integer) - Internal status code - **data** (object) - The parsed content object - **title** (string) - Page title - **url** (string) - The original URL - **content** (string) - The extracted text content - **usage** (object) - Token usage statistics #### Response Example { "code": 200, "status": 20000, "data": { "title": "Example Domain", "url": "https://example.com/", "content": "This domain is for use in illustrative examples...", "usage": { "tokens": 42 } } } ``` -------------------------------- ### Count Tokens with GET Request Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/segmenter.html Use a GET request to the segment.jina.ai endpoint to count tokens in a given content string. The 'content' parameter should be URL-encoded. ```bash https://segment.jina.ai/?content= ``` -------------------------------- ### Meta-Prompt API Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/index-gen.txt This endpoint allows you to query information using natural language. It supports GET requests and requires authentication. ```APIDOC ## GET /jina-ai/meta-prompt ### Description This endpoint is used to query information using natural language prompts. It returns structured JSON data or plain text depending on the request. ### Method GET ### Endpoint `https://s.jina.ai/` ### Parameters #### Query Parameters - **param_key** (string) - Optional - Example URL parameter. #### Headers - **Accept**: `application/json` - Response format, required. - **Authorization**: `Bearer ` - Authentication token, required. - **Content-Type**: `application/json` - Request body format, optional. - **X-Custom-Header**: `value` - Example of a custom header, optional. ### Request Body - **request_key** (string) - Optional - Example request body data. ### Request Example ```json { "request_key": "request_value" } ``` ### Response #### Success Response (200) - **code** (integer) - HTTP status code indicating success. - **status** (integer) - Application-specific status code. - **data** (array) - An array of objects containing the response details. - **title** (string) - The title of the response item. - **description** (string) - A description of the response item. - **url** (string) - A URL associated with the response item. - **content** (string) - Detailed content of the response. - **usage** (object) - Usage statistics. - **tokens** (integer) - Number of tokens used. #### Response Example (JSON) ```json { "code": 200, "status": 20000, "data": [ { "title": "Jina AI - Your Search Foundation, Supercharged.", "description": "Description of the response", "url": "https://jina.ai/", "content": "Detailed content of the response ...", "usage": { "tokens": 11091 } } ] } ``` #### Response Example (Text) Plain text response, potentially containing key-value pairs or summaries. ``` -------------------------------- ### GET /g.jina.ai/{query} Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/g.reader.html Performs fact-checking on a provided query string. ```APIDOC ## GET /g.jina.ai/{query} ### Description Performs fact-checking on a provided query string by verifying it against web references. ### Method GET ### Endpoint https://g.jina.ai/{query} ### Parameters #### Path Parameters - **query** (string) - Required - The statement or query to be fact-checked. ### Request Example curl 'https://g.jina.ai/Jina%20AI%20was%20founded%20in%202020%20in%20Berlin.' \ -H "Accept: application/json" \ -H "Authorization: Bearer " ### Response #### Success Response (200) - **code** (integer) - HTTP status code - **status** (integer) - Internal status code - **data** (object) - Contains factuality, result, reason, references, and usage tokens. #### Response Example { "code": 200, "status": 20000, "data": { "factuality": 1, "result": true, "reason": "The statement is supported by multiple references.", "references": [ { "url": "https://medium.com/jina-ai/2020-year-in-review-4896f7208fb0", "keyQuote": "Jina AI was founded in February 2020...", "isSupportive": true } ], "usage": { "tokens": 7520 } } } ``` -------------------------------- ### Grounding API JSON Response Example Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/g.reader.html This is an example of a successful JSON response from the grounding API. It includes the factuality score, result, reasoning, supporting references, and token usage. ```json { "code": 200, "status": 20000, "data": { "factuality": 1, "result": true, "reason": "The statement that Jina AI was founded in 2020 in Berlin is supported by multiple references. The first reference confirms the founding year as 2020, while the subsequent references explicitly state that Jina AI is based in Berlin, Germany. Therefore, both components of the statement are corroborated by the available evidence, making it factually correct.", "references": [ { "url": "https://medium.com/jina-ai/2020-year-in-review-4896f7208fb0", "keyQuote": "Jina AI was founded in February 2020, in the midst of a global pandemic and economic slowdown.", "isSupportive": true }, { "url": "https://www.cbinsights.com/company/jina-ai", "keyQuote": "It was founded in 2020 and is based in Berlin, Germany.", "isSupportive": true }, { "url": "https://www.jinaai.cn/about-us/", "keyQuote": "Founded in 2020 and based in Berlin, Germany, Jina AI has swiftly risen as a leader in multimodal AI", "isSupportive": true }, { "url": "https://www.linkedin.com/company/jinaai", "keyQuote": "Founded in February 2020, Jina AI has swiftly emerged as a global pioneer in multimodal AI technology.", "isSupportive": true } ], "usage": { "tokens": 7520 } } } ``` -------------------------------- ### API Response Structure Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/reranker.html Example of a successful 200 OK response from the Reranker API, containing the model name, usage statistics, and ranked results. ```json { "model": "jina-reranker-v2-base-multilingual", "usage": { "total_tokens": 815 }, "results": [ { "index": 0, "document": { "text": "Organic skincare for sensitive skin with aloe vera and chamomile: Imagine the soothing embrace of nature with our organic skincare range, crafted specifically for sensitive skin. Infused with the calming properties of aloe vera and chamomile, each product provides gentle nourishment and protection. Say goodbye to irritation and hello to a glowing, healthy complexion." }, "relevance_score": 0.8783142566680908 }, { "index": 6, "document": { "text": "针对敏感肌专门设计的天然有机护肤产品:体验由芦荟和洋甘菊提取物带来的自然呵护。我们的护肤产品特别为敏感肌设计,温和滋润,保护您的肌肤不受刺激。让您的肌肤告别不适,迎来健康光彩。" } ``` -------------------------------- ### POST /v1/train Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/classifier-train-text.html This endpoint allows you to train a custom classifier using provided text examples and labels. You can specify the model, access level, number of training iterations, and the input data. ```APIDOC ## POST /v1/train ### Description Trains a custom classifier with provided text examples and labels. ### Method POST ### Endpoint https://api.jina.ai/v1/train ### Parameters #### Request Body - **model** (string) - Required - The name of the model to use for training (e.g., "jina-embeddings-v3"). - **access** (string) - Optional - Specifies the access level for the classifier. Can be "public" or "private". Defaults to "private". - **num_iters** (integer) - Optional - Controls the training intensity. Higher values improve accuracy but increase token cost. Defaults to 10. - **input** (array) - Required - An array of training examples, where each example is an object with "text" and "label" fields. - **text** (string) - Required - The input text for the training example. - **label** (string) - Required - The label associated with the input text. ### Request Example ```json { "model": "jina-embeddings-v3", "access": "private", "num_iters": 10, "input": [ { "text": "Calculate the compound interest on a principal of $10,000 invested for 5 years at an annual rate of 5%, compounded quarterly.", "label": "Simple task" }, { "text": "分析使用CRISPR基因编辑技术在人类胚胎中的伦理影响。考虑潜在的医疗益处和长期社会后果。", "label": "Complex reasoning" }, { "text": "AIが自意識を持つディストピアの未来を舞台にした短編小説を書いてください。人間とAIの関係や意識の本質をテーマに探求してください。", "label": "Creative writing" }, { "text": "Erklären Sie die Unterschiede zwischen Merge-Sort und Quicksort-Algorithmen in Bezug auf Zeitkomplexität, Platzkomplexität und Leistung in der Praxis.", "label": "Complex reasoning" }, { "text": "Write a poem about the beauty of nature and its healing power on the human soul.", "label": "Creative writing" }, { "text": "Translate the following sentence into French: The quick brown fox jumps over the lazy dog.", "label": "Simple task" } ] } ``` ### Response #### Success Response (200) - **usage** (object) - Information about token usage. - **total_tokens** (integer) - The total number of tokens used. - **data** (array) - An array of classification results. - **object** (string) - The type of object, always "classification". - **index** (integer) - The index of the classification result. - **prediction** (string) - The predicted label for the input. - **score** (float) - The confidence score for the prediction. - **predictions** (array) - An array of all possible label predictions and their scores. - **label** (string) - The label name. - **score** (float) - The confidence score for this label. #### Response Example ```json { "usage": { "total_tokens": 196 }, "data": [ { "object": "classification", "index": 0, "prediction": "Simple task", "score": 0.35216382145881653, "predictions": [ { "label": "Simple task", "score": 0.35216382145881653 }, { "label": "Complex reasoning", "score": 0.3412695527076721 }, { "label": "Creative writing", "score": 0.3065665662288666 } ] }, { "object": "classification", "index": 1, "prediction": "Complex reasoning", "score": 0.34310275316238403, "predictions": [ { "label": "Simple task", "score": 0.32429200410842896 }, { "label": "Complex reasoning", "score": 0.34310275316238403 }, { "label": "Creative writing", "score": 0.3326052129268646 } ] }, { "object": "classification", "index": 2, "prediction": "Creative writing", "score": 0.3487184941768646, "predictions": [ { "label": "Simple task", "score": 0.3321263790130615 }, { "label": "Complex reasoning", "score": 0.31915512681007385 }, { "label": "Creative writing", "score": 0.3487184941768646 } ] }, { "object": "classification", "index": 3, "prediction": "Complex reasoning" } ] } ``` ``` -------------------------------- ### GET /v1/classifiers Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/classifier-manage.html Retrieves a list of all classifiers created by the user. ```APIDOC ## GET /v1/classifiers ### Description List all classifiers you have created. ### Method GET ### Endpoint https://api.jina.ai/v1/classifiers ### Response #### Success Response (200) - **classifier_id** (string) - Unique identifier for the classifier - **model_name** (string) - Name of the model used - **labels** (array) - List of classification labels - **access** (string) - Access level (e.g., private) - **updated_number** (integer) - Number of updates - **used_number** (integer) - Number of times used - **created_at** (string) - Timestamp of creation - **updated_at** (string) - Timestamp of last update - **used_at** (string|null) - Timestamp of last usage - **metadata** (object) - Additional metadata #### Response Example [ { "classifier_id": "6db95bec-a2c4-4544-91de-11b863ba2bd9", "model_name": "jina-clip-v1", "labels": ["Food and Dining", "Nature and Outdoors"], "access": "private", "updated_number": 1, "used_number": 0, "created_at": "2024-10-30T12:51:51.241620+00:00", "updated_at": "2024-10-30T12:51:51.241620+00:00", "used_at": null, "metadata": {} } ] ``` -------------------------------- ### Requesting content via JavaScript fetch Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/r.reader.html Perform a GET request to the Jina AI Reader API using the Fetch API. ```javascript fetch('https://r.jina.ai/https://example.com', { method: 'GET', headers: { "Authorization": "Bearer jina_74e70f6c60524b30811f57587baeece4EeJ603iFt-LCsemqEJHOJzLzgRnq", "Accept": "application/json" }, }) ``` -------------------------------- ### GET https://g.jina.ai Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/index-gen.txt Performs fact-checking and grounding on a provided query string. ```APIDOC ## GET https://g.jina.ai ### Description Grounding API to fact-check a query string. ### Method GET ### Endpoint https://g.jina.ai ### Parameters #### Query Parameters - **search_parameters** (string) - Optional - Additional search parameters. - **reference_urls** (string) - Optional - Comma-separated list of URLs for grounding references. - **use_post** (boolean) - Optional - Use POST instead of GET. - **json_response** (boolean) - Required - Indicates if the response will be in JSON format. - **use_proxy** (boolean) - Optional - Whether to use a proxy server. - **bypass_cache** (boolean) - Optional - To bypass the cache. - **browser_locale** (string) - Optional - To control the browser locale. ### Response #### Success Response (200) - **code** (integer) - HTTP status code. - **status** (integer) - Custom status code. - **data** (object) - Contains factuality score, result, reasoning, and references. ``` -------------------------------- ### Request Grounding via g.reader API Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/index-gen.txt Sends a GET request to the g.reader API to fact-check a query. Requires an authorization token and specific parameters for grounding configuration. ```python endpoint = "https://g.jina.ai" # The base URL to the grounding API (required) query = "Jina AI was founded in 2020 in Berlin." # Query string to be fact-checked (required) headers = { "Accept": "application/json", # Indicates that the response should be in JSON format (required) "Authorization": "Bearer " # Authentication token to access the API (required) } params = { "search_parameters": "", # Additional search parameters or headers (optional) "reference_urls": "", # Comma-separated list of URLs for grounding references (optional) "use_post": False, # Use POST instead of GET method, boolean value (optional) "json_response": True, # Indicates if the response will be in JSON format, boolean value (required) "use_proxy": False, # Whether to use a proxy server, boolean value (optional) "bypass_cache": False, # To bypass the cache, boolean value (optional) "browser_locale": "" # To control the browser locale, string value (optional) } response = requests.get(endpoint, params=params, headers=headers) # Sends a GET request to the API ``` -------------------------------- ### Train Classifier with Text Data Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/classifier-train-text-image.html Use this snippet to train a classifier with text-based training data. Ensure you provide a valid classifier ID and training examples with corresponding labels. ```bash curl https://api.jina.ai/v1/train \ -H "Content-Type: application/json" \ -H "Authorization: Bearer jina_74e70f6c60524b30811f57587baeece4EeJ603iFt-LCsemqEJHOJzLzgRnq" \ -d @- <", # Required: Authentication token to validate the request "Accept": "application/json" # Optional: Indicates that the client expects a JSON response } # Data payload containing the training parameters and input data data = { "model": "jina-embeddings-v3", # Required: Specifies the model to be used for training "access": "private", # Required: Determines if the model is publicly accessible or private "num_iters": 10, # Optional: Number of training iterations, defaults to a value that optimizes performance "input": [ # Required: Input data for training the model { "text": "Calculate the compound interest on a principal of $10,000 invested for 5 years at an annual rate of 5%, compounded quarterly.", "label": "Simple task" }, # Additional input data objects... ] } # Making a POST request to the endpoint with headers and data response = requests.post(endpoint, json=data, headers=headers) ``` -------------------------------- ### Default Meta-Prompt Access via Curl Source: https://github.com/jina-ai/meta-prompt/blob/main/index.html This command demonstrates how to access the default version of the Meta-Prompt content. It's a simple curl command for direct text retrieval. ```bash curl docs.jina.ai ``` -------------------------------- ### Jina Embeddings API Response Structure Source: https://github.com/jina-ai/meta-prompt/blob/main/experiment/html-snippets/embeddings.html This is an example of a successful response from the Jina embeddings API. It includes the model used, usage statistics, and a list of embeddings, each with an index and the embedding vector. ```json { "model": "jina-clip-v1", "object": "list", "usage": { "total_tokens": 5033, "prompt_tokens": 5033 }, "data": [ { "object": "embedding", "index": 0, "embedding": [ -0.008161531, 0.0040345504, -0.037822176, -0.012172974, -0.06706689, ... ] }, { "object": "embedding", "index": 1, "embedding": [ -0.032783166, 0.005709158, -0.05175277, 0.018007655, -0.026261164, ... ] }, { "object": "embedding", "index": 2, "embedding": [ -0.04354628, 0.014823603, -0.0219809, 0.013545886, -0.08526429, ... ] }, { "object": "embedding", "index": 3, "embedding": [ -0.021557946, 0.010585106, 0.014772621, -0.062192347, 0.01447019, ... ] }, { "object": "embedding", "index": 4, "embedding": [ -0.05983584, 0.012545062, 0.0022877986, 0.03144552, 0.0013024239, ... ] } ] } ```