NAME

WebService::Jina - Jina client

VERSION

Version 0.01

SYNOPSIS

	use WebService::Jina;

	my $jina = WebService::Jina->new(
		api_key => '...'
	);
	
	...

	my $deepsearch = $jina->deepsearch(
		messages => [
			{
				role => "user",
				content => "Hi!"
			},
			{
				role => "assistant",
				content => "Hi, how can I help you?"
			},
			{
				role => "user",
				content => "what's the latest blog post from jina ai?"
			}
		]
	);

	...

	my $reader = $jina->reader("https://lnation.org");

	...

	my $embed = $jina->embedding(
		input => [
	        	{
                        	text => "A beautiful sunset over the beach"
                	},
                	{
                        	text => "Un beau coucher de soleil sur la plage"
                	}
		]
	);

	...

	my $rerank = $jina->rerank(
		query => "Organic skincare products for sensitive skin",
		documents => [
			"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.",
			"New makeup trends focus on bold colors and innovative techniques: Step into the world of cutting-edge beauty with this seasons makeup trends. Bold, vibrant colors and groundbreaking techniques are redefining the art of makeup. From neon eyeliners to holographic highlighters, unleash your creativity and make a statement with every look.",
			"Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille: Erleben Sie die wohltuende Wirkung unserer Bio-Hautpflege, speziell für empfindliche Haut entwickelt. Mit den beruhigenden Eigenschaften von Aloe Vera und Kamille pflegen und schützen unsere Produkte Ihre Haut auf natürliche Weise. Verabschieden Sie sich von Hautirritationen und genießen Sie einen strahlenden Teint.",
			"Neue Make-up-Trends setzen auf kräftige Farben und innovative Techniken: Tauchen Sie ein in die Welt der modernen Schönheit mit den neuesten Make-up-Trends. Kräftige, lebendige Farben und innovative Techniken setzen neue Maßstäbe. Von auffälligen Eyelinern bis hin zu holografischen Highlightern – lassen Sie Ihrer Kreativität freien Lauf und setzen Sie jedes Mal ein Statement.",
			"Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla: Descubre el poder de la naturaleza con nuestra línea de cuidado de la piel orgánico, diseñada especialmente para pieles sensibles. Enriquecidos con aloe vera y manzanilla, estos productos ofrecen una hidratación y protección suave. Despídete de las irritaciones y saluda a una piel radiante y saludable.",
			"Las nuevas tendencias de maquillaje se centran en colores vivos y técnicas innovadoras: Entra en el fascinante mundo del maquillaje con las tendencias más actuales. Colores vivos y técnicas innovadoras están revolucionando el arte del maquillaje. Desde delineadores neón hasta iluminadores holográficos, desata tu creatividad y destaca en cada look.",
			"针对敏感肌专门设计的天然有机护肤产品:体验由芦荟和洋甘菊提取物带来的自然呵护。我们的护肤产品特别为敏感肌设计
	,温和滋润,保护您的肌肤不受刺激。让您的肌肤告别不适,迎来健康光彩。",
			"新的化妆趋势注重鲜艳的颜色和创新的技巧:进入化妆艺术的新纪元,本季的化妆趋势以大胆的颜色和创新的技巧为主。无
	论是霓虹眼线还是全息高光,每一款妆容都能让您脱颖而出,展现独特魅力。",
			"敏感肌のために特別に設計された天然有機スキンケア製品: アロエベラとカモミールのやさしい力で、自然の抱擁を感じ
	てください。敏感肌用に特別に設計された私たちのスキンケア製品は、肌に優しく栄養を与え、保護します。肌トラブルにさようなら、輝>く健康な肌にこんにちは。",
			"新しいメイクのトレンドは鮮やかな色と革新的な技術に焦点を当てています: 今シーズンのメイクアップトレンドは、大
	胆な色彩と革新的な技術に注目しています。ネオンアイライナーからホログラフィックハイライターまで、クリエイティビティを解き放ち>、毎回ユニークなルックを演出しましょう。"
		]
	);

	...

	my $classify = $jina->classify(
		input => [
			{
				text => "A sleek smartphone with a high-resolution display and multiple camera lenses"
			},
			{
				text => "Fresh sushi rolls served on a wooden board with wasabi and ginger"
			},
			{
				image => "https://picsum.photos/id/11/367/267"
			},
			{
				image => "https://picsum.photos/id/22/367/267"
			},
			{
				text => "Vibrant autumn leaves in a dense forest with sunlight filtering through"
			},
			{
				image => "https://picsum.photos/id/8/367/267"
			}

		],
		labels => [
			"Technology and Gadgets",
			"Food and Dining",
			"Nature and Outdoors",
			"Urban and Architecture"
		]
	);	

	...

	my $segment = $jina->segment(
		content => "\n  Jina AI: Your Search Foundation, Supercharged! 🚀\n  Ihrer Suchgrundlage, aufgeladen! 🚀\n  您的搜索>底座,从此不同!🚀\n  検索ベース,もう二度と同じことはありません!🚀\n"
	);	

ABOUT

See https://jina.ai/

SUBROUTINES/METHODS

deepsearch

DeepSearch combines web searching, reading, and reasoning for comprehensive investigation. Think of it as an agent that you give a research task to - it searches extensively and works through multiple iterations before providing an answer. This process involves continuous research, reasoning, and approaching the problem from various angles. This is fundamentally different from standard LLMs that generate answers directly from pretrained data, and from traditional RAG systems that rely on one-time, surface-level searches.

my $deepsearch = $jina->deepsearch(
	stream => 1,
	stream_cb => sub {
		my ($res) = @_;
		...
	},
	messages => [
		{
			role => "user",
			content => "Hi!"
		},
		{
			role => "assistant",
			content => "Hi, how can I help you?"
		},
		{
			role => "user",
			content => "what's the latest blog post from jina ai?"
		}
	]
);

reader

Feeding web information into LLMs is an important step of grounding, yet it can be challenging. The simplest method is to scrape the webpage and feed the raw HTML. However, scraping can be complex and often blocked, and raw HTML is cluttered with extraneous elements like markups and scripts. The Reader API addresses these issues by extracting the core content from a URL and converting it into clean, LLM-friendly text, ensuring high-quality input for your agent and RAG systems.

my $reader = $jina->reader("https://lnation.org");

embedding

Top-performing multimodal multilingual long-context embeddings for search, RAG, agents applications.

my $embed = $jina->embedding(
	input => [
	       	{
		    	text => "A beautiful sunset over the beach"
		},
		{
			text => "Un beau coucher de soleil sur la plage"
		},
		{
		    	text => "海滩上美丽的日落"
		},
		{
		    	text => "浜辺に沈む美しい夕日"
		},
		{
		    	image => "https://i.ibb.co/nQNGqL0/beach1.jpg"
		},
		{
		    	image => "https://i.ibb.co/r5w8hG8/beach2.jpg"
		},
		{
			image => "R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"
		}
	]
);

rerank

The goal of a search system is to find the most relevant results quickly and efficiently. Traditionally, methods like BM25 or tf-idf have been used to rank search results based on keyword matching. Recent methods, such as embedding-based cosine similarity, have been implemented in many vector databases. These methods are straightforward but can sometimes miss the subtleties of language, and most importantly, the interaction between documents and a query's intent.

This is where the "reranker" shines. A reranker is an advanced AI model that takes the initial set of results from a search—often provided by an embeddings/token-based search—and reevaluates them to ensure they align more closely with the user's intent. It looks beyond the surface-level matching of terms to consider the deeper interaction between the search query and the content of the documents.

my $rerank = $jina->rerank(
	query => "Organic skincare products for sensitive skin",
	documents => [
		"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.",
		"New makeup trends focus on bold colors and innovative techniques: Step into the world of cutting-edge beauty with this seasons makeup trends. Bold, vibrant colors and groundbreaking techniques are redefining the art of makeup. From neon eyeliners to holographic highlighters, unleash your creativity and make a statement with every look.",
		"Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille: Erleben Sie die wohltuende Wirkung unserer Bio-Hautpflege, speziell für empfindliche Haut entwickelt. Mit den beruhigenden Eigenschaften von Aloe Vera und Kamille pflegen und schützen unsere Produkte Ihre Haut auf natürliche Weise. Verabschieden Sie sich von Hautirritationen und genießen Sie einen strahlenden Teint.",
		"Neue Make-up-Trends setzen auf kräftige Farben und innovative Techniken: Tauchen Sie ein in die Welt der modernen Schönheit mit den neuesten Make-up-Trends. Kräftige, lebendige Farben und innovative Techniken setzen neue Maßstäbe. Von auffälligen Eyelinern bis hin zu holografischen Highlightern – lassen Sie Ihrer Kreativität freien Lauf und setzen Sie jedes Mal ein Statement.",
		"Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla: Descubre el poder de la naturaleza con nuestra línea de cuidado de la piel orgánico, diseñada especialmente para pieles sensibles. Enriquecidos con aloe vera y manzanilla, estos productos ofrecen una hidratación y protección suave. Despídete de las irritaciones y saluda a una piel radiante y saludable.",
		"Las nuevas tendencias de maquillaje se centran en colores vivos y técnicas innovadoras: Entra en el fascinante mundo del maquillaje con las tendencias más actuales. Colores vivos y técnicas innovadoras están revolucionando el arte del maquillaje. Desde delineadores neón hasta iluminadores holográficos, desata tu creatividad y destaca en cada look.",
		"针对敏感肌专门设计的天然有机护肤产品:体验由芦荟和洋甘菊提取物带来的自然呵护。我们的护肤产品特别为敏感肌设计
,温和滋润,保护您的肌肤不受刺激。让您的肌肤告别不适,迎来健康光彩。",
		"新的化妆趋势注重鲜艳的颜色和创新的技巧:进入化妆艺术的新纪元,本季的化妆趋势以大胆的颜色和创新的技巧为主。无
论是霓虹眼线还是全息高光,每一款妆容都能让您脱颖而出,展现独特魅力。",
		"敏感肌のために特別に設計された天然有機スキンケア製品: アロエベラとカモミールのやさしい力で、自然の抱擁を感じ
てください。敏感肌用に特別に設計された私たちのスキンケア製品は、肌に優しく栄養を与え、保護します。肌トラブルにさようなら、輝>く健康な肌にこんにちは。",
		"新しいメイクのトレンドは鮮やかな色と革新的な技術に焦点を当てています: 今シーズンのメイクアップトレンドは、大
胆な色彩と革新的な技術に注目しています。ネオンアイライナーからホログラフィックハイライターまで、クリエイティビティを解き放ち>、毎回ユニークなルックを演出しましょう。"
	]
);

classify

The Classifier is an API service that categorizes text and images using embedding models (jina-embeddings-v3 and jina-clip-v1), supporting both zero-shot classification without training data and few-shot learning with minimal examples.

my $classify = $jina->classify(
	input => [
		{
			text => "A sleek smartphone with a high-resolution display and multiple camera lenses"
		},
		{
			text => "Fresh sushi rolls served on a wooden board with wasabi and ginger"
		},
		{
			image => "https://picsum.photos/id/11/367/267"
		},
		{
			image => "https://picsum.photos/id/22/367/267"
		},
		{
			text => "Vibrant autumn leaves in a dense forest with sunlight filtering through"
		},
		{
			image => "https://picsum.photos/id/8/367/267"
		}

	],
	labels => [
		"Technology and Gadgets",
		"Food and Dining",
		"Nature and Outdoors",
		"Urban and Architecture"
	]
);	

segment

A segmenter is a crucial component that converts text into tokens or chunks, which are the basic units of data that an embedding/reranker model or LLM processes. Tokens can represent whole words, parts of words, or even individual characters.

my $segment = $jina->segment(
	content => "\n  Jina AI: Your Search Foundation, Supercharged! 🚀\n  Ihrer Suchgrundlage, aufgeladen! 🚀\n  您的搜索>底座,从此不同!🚀\n  検索ベース,もう二度と同じことはありません!🚀\n"
);	

AUTHOR

lnation, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-webservice-jina at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-Jina. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc WebService::Jina

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2025 by lnation.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)